]> git.nbdom.net Git - nb.git/commitdiff
sort and extras in db.yaml
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Dec 2015 19:35:35 +0000 (19:35 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Dec 2015 19:35:35 +0000 (19:35 +0000)
lib/php/db/table.php

index d07bb0cd65cfacf36da9a387a211ca7a8694941d..cd58204b70f482a03f0c2fc5eab00e5e3250b99a 100644 (file)
@@ -41,7 +41,7 @@ class table extends nb {
       $this->db = new db();
     }
 
-    // Table could be a select
+    // Name, could be a select
     if (stripos($name,'SELECT ')===0) {
       #$temp = '_'.substr(md5($name),0,6);
       $temp = '_query_';
@@ -53,7 +53,23 @@ class table extends nb {
 
     $this->name = $name;
 
-    if (isset($opt['extras'])) $this->add_extras($opt['extras']);
+    // Extras
+    if (isset($opt['extras'])) {
+      $this->add_extras($opt['extras']);
+
+    } elseif (
+      isset($this->db->extras)
+      and isset($this->db->extras[$this->name])
+    ) {
+      $this->add_extras($this->db->extras[$this->name]);
+
+    }
+
+    // Sort
+    if (
+      isset($this->db->sort)
+      and isset($this->db->sort[$this->name])
+    ) $this->db->pset('sort',$this->db->sort[$this->name]);
 
     return $this->fields();
   }