]> git.nbdom.net Git - nb.git/commitdiff
dbs order
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 15 Aug 2016 10:36:14 +0000 (12:36 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 15 Aug 2016 10:36:14 +0000 (12:36 +0200)
etc/dbs.yaml
lib/php/db.php

index eecf9fbf988f2896cabb590041ab91d9c8e54fc4..16eeb8ad9ffc7d60ffca753b7db75bcd1e68e3cc 100644 (file)
@@ -16,12 +16,14 @@ rt:
   title: 'RT'
 
 izi:
-  title: Mysql Izi
-  host: sql.izideal.vpn
+  title: Izi Admin
+  host: admin.izideal.vpn
   default_table: process
   user: izideal
   name: izi
   type: mysql
+  _import:
+    - _izi
   tables:
     site:
       replace:
@@ -33,13 +35,7 @@ izi-sql:
   _import:
     - izi
 
-izi:
-  title: Mysql Izi Master
-  host: admin.izideal.vpn
-  _import:
-    - izi
-
-izidev:
+izi-dev:
   host: big.cascais.loc
   title: Mysql Izi on Big
   #user: nico
index a863fe077b501eb2604149e073f74de120395808..4ed9fb3b11b4f8c14c3d60aaaff9d197ed6dca41 100644 (file)
@@ -416,7 +416,7 @@ class Db extends nb {
         } elseif ($action == 'db.dbs' or $action == 'dbs') {
           if (true or self::p('hash') or self::p('all')) {
 
-            $fields = ['id','name','title','type','host'];
+            $fields = ['id','name','title','type','host','order'];
             $dbs = [];
             $name = self::p('name','');
             $type = self::p('type','');
@@ -505,11 +505,20 @@ class Db extends nb {
     foreach ($h as $db=>$o) { if (preg_match('/^_/',$db)) unset($h[$db]); }
 
     # Add missing name
-    foreach ($h as $db=>$o) { if (empty($o['name'])) $h[$db]['name'] = $db; }
+    foreach ($h as $db=>$o) {
+      if (empty($o['name'])) $h[$db]['name'] = $db;
+      if (empty($o['id'])) $h[$db]['id'] = $db;
+    }
 
     # Sort
 
-    uasort($h,create_function('$a,$b','$a_=isset($a["order"])?$a["order"]:-1;$b_=isset($b["order"])?$b["order"]:-1; return($b_-$a_);'));
+    uasort($h,function($a,$b){
+      if (empty($a["order"]) and empty($b["order"])) return strcmp($a['id'],$b['id']);
+      $a_ = isset($a["order"]) ? $a["order"] : -1;
+      $b_ = isset($b["order"]) ? $b["order"] : -1;
+      return($b_-$a_);
+    });
+
     if (!$h) return false;
     if ($first !== false) $first = self::ar_first($h);
     return $h;