*/
static function conf_dbs($files=array(),&$first=false) {
if (empty($files)) return array();
- if (is_scalar($files)) $files = array($files);
- # Load all files into a hash
+ # Load all files into a $h if #files is not a hash
+
$h = array();
+ if (is_scalar($files)) $files = array($files);
+
foreach ($files as $file) {
if (is_readable($file) and ($yaml = yaml_parse_file($file))) {
#foreach ($yaml as $k=>$v) { $yaml[$k]['_conf_dbs'] = $file; }
# Add missing name
foreach ($h as $db=>$o) { if (empty($o['name'])) $h[$db]['name'] = $db; }
+ # Sort
+
+ self::hksort($h,'order');
if (!$h) return false;
#self::bye($h['puppetdb']);
#if ($first !== false) debug ( self::ar_first($h) );
if (isset($Db)) self::bye("Db.init(): GLOBALS['Db'] already exists !");
$Db = new self();
- #bye($_SERVER["PHP_SELF"]); bye($_SERVER);
-# NB 19.03.16 if (!in_array(nb::$root_dir.'/etc/dbs.yaml',$conf)) $conf[] = nb::$root_dir.'/etc/dbs.yaml';
-# NB 19.03.16 if (!in_array('/etc/dbs.yaml',$conf)) $conf[] = '/etc/dbs.yaml';
# Load databases
- if (! ($dbs = $Db->conf_dbs($conf)) ) return false;
- $Db->hksort($dbs,'order');
+ $dbs = self::is_hash($conf) ? $conf : $Db->conf_dbs($conf);
+ if (!$dbs) return false;
+ #if (! ($dbs = $Db->conf_dbs($conf)) ) return false;
#bye($dbs['nb']);
#die (nb::p('db'));