]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 20:04:33 +0000 (20:04 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 20:04:33 +0000 (20:04 +0000)
etc/dbq/pub.php
lib/php/db.php
www/dbq/dbq.php

index 000f8e1a99f643cacd126f566e89a028aa2673ee..3fdcec2648bb239d451daad340be53d1c2670b9e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-return;
 require_once(realpath(dirname(__FILE__).'/../../lib/php/maps.php'));
 function pub_map(&$r) {
+       debug($r);
        if (empty($r['latitude'])) return;
        if (empty($r['longiture'])) return;
        $r['maps'] = '<a href="'.Maps::link($r['latitude'],$r['latitude']).'">'
@@ -10,8 +10,9 @@ function pub_map(&$r) {
 }
 
 $DBQ['pub'] = [
-       'tables' => [
-               'zipcode' => [ 'extras' => ['maps' => ''] ],
-       ],
+       'row_parse_post' => function(&$r,&$t) {
+               #debug('zaza');
+               #pub_map($r);
+       },
 ];
 ?>
index 7f5e9f294b0fcc1f60cdf2d2375e0e590cbe538a..3db5c74867f67ad45a833af041f94c622a0c0efe 100644 (file)
@@ -678,6 +678,19 @@ class Db extends nb {
   * @param [FILES] $files Files to load
   * @return ARRAY the new/existing value of $this->db
   */
+  public static function ar_merge($a,$b) {
+               return array_replace_recursive($a,$b);
+               #return array_combine($a,$b);
+               $n = $a;
+               foreach ($b as $k=>$v) {
+                       if (!empty($n[$k]) and is_array($v)) {
+                               $v = array_combine($n[$k],$v);
+                       }
+                       $n[$k] = $v;
+               }
+               return $n;
+       }
+
   public static function conf_load($files=[],&$first=false) {
     if (empty($files)) return [];
 
@@ -696,11 +709,12 @@ class Db extends nb {
 
       if (!is_readable($file)) continue;
       if (preg_match('/\.(yaml|yml)$/i',$file) and ($yaml = self::yaml_parse_file($file))) {
-        $dbs = array_replace_recursive($dbs,$yaml);
+        $dbs = self::ar_merge($dbs,$yaml);
 
       } elseif (preg_match('/\.php$/i',$file)) {
+                               $DBQ = [];
         require($file);
-        if (!empty($DBQ)) $dbs = array_replace_recursive($dbs,$DBQ);
+        if (!empty($DBQ)) $dbs = self::ar_merge($dbs,$DBQ);
 
       }
 
index 6c192587c51fd65274db2355b1ef6c98da55b9b4..777048b18150efc57a728707f2436075e4013ef7 100644 (file)
@@ -328,6 +328,7 @@ class DbQ extends nb {
                                        $this->not_found('Unknown db: '.$this->params['db']);
                                $connect = $this->db->conf[$this->params['db']];
                        }
+                       #debug($connect);
 
                        $connect['id'] = $this->params['db'];
 
@@ -447,7 +448,6 @@ class DbQ extends nb {
 
     if (!empty($this->db()->row_parse_post)) {
       $row_parse_post = $this->db()->row_parse_post;
-      $call($r,$this);
     }
 
                $opt = ($this->page->is('html')