]> git.nbdom.net Git - nb.git/commitdiff
fix bug in select_extras
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Mon, 17 Oct 2016 13:30:44 +0000 (14:30 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Mon, 17 Oct 2016 13:30:44 +0000 (14:30 +0100)
lib/php/db/table.php

index ed5b32ba6e63940623c5f62e89ead7f655e8d7a7..6e4663ee5f8c25e7c5b09b6c0e93728cdbe4e2e8 100644 (file)
@@ -37,7 +37,7 @@ Class Table extends nb {
     , 'page', 'paged' # wordpress
   ];
 
-  public $fields;
+  public $fields = [];
   public $indexes;
 
   function __construct($name,$opt=[]) {
@@ -266,9 +266,9 @@ Class Table extends nb {
 
     $this->create_temporary();
 
-    if (!isset($this->fields)) {
+    if (!isset($this->_fields)) {
+      $this->_fields = true;
 
-      $this->fields = array();
       $conf = $this->unvar($this->db()->conf_type('table.fields',true));
       if (is_scalar($conf)) $conf = array('sql'=>$conf);
       $rows = $this->db()->conn->query($conf['sql']);
@@ -665,6 +665,7 @@ Class Table extends nb {
       $select[] = $field->extras." AS ".$field->sql_name();
     }
 
+    if (!$select) return '';
     return ','.join(',',$select);
   }