From f5b039ddba92374b6fb6e400c18533a4b10d6519 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sat, 6 Jan 2018 20:04:33 +0000 Subject: [PATCH] www/dbq/dbq.php --- etc/dbq/pub.php | 9 +++++---- lib/php/db.php | 18 ++++++++++++++++-- www/dbq/dbq.php | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/etc/dbq/pub.php b/etc/dbq/pub.php index 000f8e1a..3fdcec26 100644 --- a/etc/dbq/pub.php +++ b/etc/dbq/pub.php @@ -1,7 +1,7 @@ ' @@ -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); + }, ]; ?> diff --git a/lib/php/db.php b/lib/php/db.php index 7f5e9f29..3db5c748 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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); } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 6c192587..777048b1 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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') -- 2.47.3