From 936b7062f150072f3b849fe2116582aba004238d Mon Sep 17 00:00:00 2001 From: Devops Date: Wed, 5 Jul 2017 12:34:55 +0100 Subject: [PATCH] lib/php/db/table.php --- lib/php/db/table.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 67104680..a5cf2aad 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -166,7 +166,7 @@ Class Table extends nb { } private function sql_temporary() { - if ($this->type == 'sqlite') return 'TEMP'; + if ($this->db()->type == 'sqlite') return 'TEMP'; return 'TEMPORARY'; } @@ -2080,15 +2080,28 @@ Class Table extends nb { } public function status($key=null) { + if (!isset($this->status)) { - $this->create_temporary(); - $sql = $this->db()->method('tables'); - if (!self::p('count')) $sql .= " LIMIT 0"; - $sql = "SELECT * FROM ($sql) t WHERE name=".$this->db()->quote($this->name); + if ($this->type == 'sql') { + + $this->status = [ + 'type' => $this->type, + 'name' => $this->name, + ]; + + } else { + + $this->create_temporary(); + $sql = $this->db()->method('tables'); + if (!self::p('count')) $sql .= " LIMIT 0"; + $sql = "SELECT * FROM ($sql) t WHERE name=".$this->db()->quote($this->name); + + $sth = $this->db()->conn->query($sql,PDO::FETCH_ASSOC); + if (!empty($sth)) $this->status = $sth->fetch(); + + } - $sth = $this->db()->conn->query($sql,PDO::FETCH_ASSOC); - if (!empty($sth)) $this->status = $sth->fetch(); if (empty($this->status)) $this->status = []; # Add to status array -- 2.47.3