]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/table.php
authorDevops <sys@15gifts.com>
Wed, 5 Jul 2017 11:34:55 +0000 (12:34 +0100)
committerDevops <sys@15gifts.com>
Wed, 5 Jul 2017 11:34:55 +0000 (12:34 +0100)
lib/php/db/table.php

index 67104680791e90ad16bf60e8a1597deac91a94e1..a5cf2aad2ba993372014ff9766a230125d2deb9a 100644 (file)
@@ -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