]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 21:07:29 +0000 (21:07 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 21:07:29 +0000 (21:07 +0000)
lib/php/db.php

index b65d3caa1cc97f9cba7e2e17fff9eb5d7e1f1e49..03bea9f540cd5d51946f4f69a085f1f53ee58cc4 100644 (file)
@@ -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);