From: Nicolas Boisselier Date: Fri, 9 Dec 2016 16:31:43 +0000 (+0000) Subject: dbq X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=dae3ff16ea59c9f2c928e1db85b5aa49c8798e3a;p=nb.git dbq --- diff --git a/lib/php/db.php b/lib/php/db.php index c0c40ac7..75ef7553 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -389,6 +389,7 @@ class Db extends nb { if (!$name) bye('table name is empty'); if (empty($params) or empty($params['db'])) $params['db'] = $this; + if (empty($this->tables[$name])) { $this->tables[$name] = new Table($name,$params); } elseif ($params) { diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 1cecac58..2dc7aeee 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -126,7 +126,13 @@ if (empty($this->_nopage)) { if (!empty($connect)) { if (!isset($this->db)) $this->db = $this->db(); - if (!is_array($connect) and $connect === true) $connect = $this->db->conf[$this->params['db']]; + + if (!is_array($connect) and $connect === true and isset($this->db->conf[$this->params['db']])) + $connect = $this->db->conf[$this->params['db']] + ; + + if (empty($connect['name'])) $this->not_implemented(); + $this->db->__construct($connect); $this->db->connect(); return $this->db; @@ -140,6 +146,7 @@ if (empty($this->_nopage)) { } public function table() { + if (!in_array($this->params['table'],array_keys($this->db->tables()))) $this->not_implemented(); $this->table = $this->db->table($this->params['table'],['db'=>$this->db]); } @@ -321,6 +328,9 @@ if (empty($this->_nopage)) { # NB 08.12.16 $this->out($e); # NB 08.12.16 return true; + } else { + $this->not_implemented(); + } return false;