From 1239495e9f37df216ec7f78c554d19af4f9a0876 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 4 Dec 2017 21:07:29 +0000 Subject: [PATCH] lib/php/db.php --- lib/php/db.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index b65d3caa..03bea9f5 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -127,7 +127,7 @@ class Db extends nb { # Classes public $out; - function __construct($opt = '') { + function __construct($opt = []) { # Args defaults if ($opt==='') $opt = []; @@ -826,28 +826,27 @@ class Db extends nb { * Create globals Db and Table */ public static function init($conf) { - global $Db, $Table; - if (isset($Table)) self::bye("Table.init(): GLOBALS['Table'] already exists !"); - if (isset($Db)) self::bye("Db.init(): GLOBALS['Db'] already exists !"); - - # - # Db - # - $Db = new self(); # # Params - $Db->pinit(); + self::pinit(); # # Load conf - $db = $Db->conf_search_db($conf); - if ($Db->p('localFile')) { - foreach ($Db->localFile($db['name']) as $k=>$v) { + $db = self::conf_search_db($conf); + if (self::p('localFile')) { + foreach (self::localFile($db['name']) as $k=>$v) { if (empty($db[$k])) $db[$k] = $v; } } + # + # Db + # + global $Db, $Table; + if (isset($Table)) self::bye("Table.init(): GLOBALS['Table'] already exists !"); + if (isset($Db)) self::bye("Db.init(): GLOBALS['Db'] already exists !"); + $Db = new self(); # # Connection $Db->__construct($db); -- 2.47.3