]> git.nbdom.net Git - nb.git/commitdiff
docker-compose
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 19 Nov 2016 16:04:26 +0000 (16:04 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 19 Nov 2016 16:04:26 +0000 (16:04 +0000)
etc/dbq.php
etc/profile.d/docker.sh
lib/php/db.php
lib/php/db/config.php
lib/php/db/table.php
lib/php/db/types/sqlite.php
lib/php/nb.php
src/Docker/Compose/dbq/docker-compose.yaml
src/Docker/Compose/up.sh [new file with mode: 0644]
src/Docker/nginx/Dockerfile
src/Docker/php/Dockerfile

index bdbe6a87e8839bcd4a5a55e98cac60d2f67ded71..be2771a0393907ad8bcdba2131eee93a1cf2d3fd 100644 (file)
@@ -8,7 +8,7 @@ $LOCAL_DB = (
 ) ? true : false;
 
 #
-# Search existing DIR_SQLITE
+# DIR_SQLITE=*/var/lib/sqlite
 #
 unset($DIR_SQLITE);
 foreach ([
@@ -86,45 +86,45 @@ $DBQ['all'] = [
 
 foreach ($DBQ as $id => $db) {
   if (0
+
     or empty($db['type'] )
     or $db['type']!='sqlite'
+
     or empty($db['host'] )
     or !is_readable($db['host'])
     or !strpos($db['host'],'.db')
+
   ) continue;
 
   $fname = basename($db['host'],'.db');
   $fname = preg_replace('/\..*$/','',basename($db['host']));
 
   $DBQ['all']['types']['sql_pre'][] = "ATTACH DATABASE '".$db['host']."' as ".$fname."";
+  if (!isset($DBQ[$fname]['name'])) $DBQ[$fname]['name'] = $fname;
   conf_merge($DBQ[$fname],$DBQ['all']);
 
 }
 conf_merge($DBQ['nb'],$DBQ['all']);
-#var_dump($DBQ['all']['types']['sql_pre']);
-
-return 1;
 
 function conf_merge(&$c1,&$c2) {
 
-  if (!empty($c1['tables'])) {
-    if (empty($c1['tables'])) $c1['tables'] = [];
-    foreach ($c1['tables'] as $k=>$v) {
-      #debug($k);
-      $c2['tables'][$k] = $v;
-    }
-  }
-
+  // .*
   foreach ([
     'default_table',
     'title',
     'row_parse',
     #'_import',
-  ] as $k) if (!empty($c1[$k]))
-    $c2[$k] = $c1[$k];
-  ;
+  ] as $k) {
+    if (isset($c1[$k])) $c2[$k] = $c1[$k];
+  }
+
+  // tables.*
+  if (!empty($c1['tables'])) {
+    foreach ((array)$c1['tables'] as $k=>$v) {
+      $c2['tables'][$k] = $v + ['database' => $c1['name']];
+    }
+  }
 
   return [$c1,$c2];
 }
-
 ?>
index 019694fecaf7d616708d094c4653629201c721c2..8f519ecc13fcd55d55194fa7cbacf6158a22f7a3 100644 (file)
@@ -17,6 +17,10 @@ if [ -z "$MYVIMRC" ]; then
   #[ -z "$DOCKER_CERT_PATH" -o ! -e "$DOCKER_CERT_PATH" ] && which docker-machine>/dev/null && docker-machine ls -q 2>/dev/null |grep -qFm1 "$DOCKER_MACHINE_NAME" && eval "$(docker-machine env "$DOCKER_MACHINE_NAME")" 2>/dev/null
 fi
 
+docker_machine_shared() {
+  VBoxManage showvminfo "$DOCKER_MACHINE_NAME" | perl -ne "print qq|\$2\t\$1\n| if /^Name: '(.*?)', Host path: '(.*?)'/"
+}
+
 docker_build() {
   
   shell_help "Usage: $FUNCNAME [DIR_DOCKERFILE]" "$@" && return
index 3902a42b6e251752ab387e94eb4a25be98b02bf3..6e014d759862dfb13a1cb105ca01f5c83a4c77f3 100644 (file)
@@ -243,8 +243,8 @@ class Db extends nb {
   }
 
        public function connect() {
-
     if (!empty($this->conn)) return false;
+
     # Pdo
     if (empty($this->pdo)) $this->bye("db: `".$this->id."`: Missing pdo: check host, name, user, password");
     if (empty($this->pdo)) return false;
@@ -253,10 +253,6 @@ class Db extends nb {
     $this->conf_type_load();
 
     # Connect
-    #debug([$this->pdo,$this->user,$this->password,$this->options]);
-    #$this->conn = new PDO($this->pdo,$this->user,$this->password);
-    #bye('zaza');
-  #if (false) {
     try {
       $this->conn = new PDO($this->pdo,$this->user,$this->password,$this->options);
       #if (isset($this->pdo_error)) $this->conn->setAttribute($this->pdo_error[0], $this->pdo_error[1]);
@@ -270,7 +266,6 @@ class Db extends nb {
       #throw new Exception($msg, (int)$e->getCode());
       self::bye($msg);
     }
-  #}
 
     if (empty($this->conn)) {
       $this->bye("Connection failed: ".$this->pdo_info());
@@ -288,7 +283,6 @@ class Db extends nb {
 
     foreach ($this->sql_pre() as $s) { $this->conn->exec($s); }
 
-    # Bye
     return true;
   }
 
@@ -297,15 +291,8 @@ class Db extends nb {
     try {
       #$r = $this->conn->exec($sql,$params);
       $r = $this->conn->exec($sql);
-      /*
-      if ($params === null) {
-        $r = $this->conn->exec($sql,$params);
-      } else {
-        $r = $this->conn->exec($sql);
-      }
-      */
     } catch (PDOException $e) {
-      err(join(': ',array($e->getMessage(),"Db.exec()",$sql)));
+      err(join(': ',[$e->getMessage(),"Db.exec()",$sql]));
       $r = null;
     }
 
@@ -313,12 +300,12 @@ class Db extends nb {
   }
 
   public function query($sql) {
-  # See: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
+    # See: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
 
     try {
       $r = $this->conn->query($sql);
     } catch (PDOException $e) {
-      err(join(': ',array($e->getMessage(),"Db.query()",$sql)));
+      err(join(': ',[$e->getMessage(),"Db.query()",$sql]));
       $r = null;
     }
 
@@ -619,6 +606,7 @@ class Db extends nb {
             #if ($this->p('fields')) $row['fields'] = $t->status('fields');
             if ($this->p('fields')) $row['fields'] = join(',',array_keys($t->fields()));
 
+            #debug($t->name.'='.$t->database);
             $rows[] = $row;
           }
 
@@ -654,7 +642,6 @@ class Db extends nb {
     #
 
     $dbs = [];
-    #if (is_scalar($files)) $files = array($files);
     foreach ((array)$files as $file) {
 
       $file = self::untilde($file);
@@ -768,11 +755,11 @@ class Db extends nb {
     if (empty($conf[$id])) return [];
 
     # Construct assoc array
-    $db = array_merge($conf[$id],array(
+    $db = array_merge($conf[$id],[
       #'dbs'  => array_keys($conf),
       'conf' => $conf,
       'id'   => $id,
-    ));
+    ]);
 
     return $db;
   }
@@ -1015,10 +1002,10 @@ class Db extends nb {
       #'conf' => count(array_keys($this->conf)),
       'tables' => count($this->tables()),
     ]
-    +($this->conf_type('use_path') ? [] : array(
+    +($this->conf_type('use_path') ? [] : [
       'port' => $this->port,
       'user' => $this->user,
-    ))
+    ])
     +$new;
 
     if (($sqls=$this->conf_type('status'))) {
@@ -1048,10 +1035,10 @@ class Db extends nb {
 
     #debug($new);
     foreach ($new as $k=>$v) {
-      $status[] = array(
+      $status[] = [
         'name' => $k,
         'value' => $v,
-      );
+      ];
     }
 
     return $status;
index fe94fa823eac52f09bc574ae28f0579c8dfa5639..994ca07e5cea2cca7b67471d4e2a775780f1e59b 100644 (file)
@@ -2,6 +2,15 @@
 require_once(realpath(dirname(__FILE__).'/../config.php'));
 require_once(realpath(dirname(__FILE__).'/../db.php'));
 
+# NB 19.11.16: TODEL 
+foreach ([
+  Db::ROOT_DIR.'/etc/dbs.yaml',
+  Db::ROOT_DIR.'/etc/dbs.php',
+  '/etc/dbs.yaml',
+] as $file) {
+  if (file_exists($file)) nb::msg("Delete obsolete file: $file (".__FILE__.")");
+}
+
 $DB_CONFS = Db::conf_load(
 glob('/etc/dbq/*.yaml')+
 glob('/etc/dbq/*.php')+
index 79a6eae252c1ee63617c806d8c620f8a4a20ff9e..2656fc756419c4dd15cf4348623a3818917de86d 100644 (file)
@@ -2,14 +2,10 @@
 require_once(realpath(dirname(__FILE__).'/../db.php'));
 require_once(realpath(dirname(__FILE__).'/../db/field.php'));
 require_once(realpath(dirname(__FILE__).'/../out.php'));
-#$a = array('a','b','c'); $b = array('c','a'); debug(array_diff($a,$b));
 
 define('TABLE_INDENT',NB_EOL ? "\t" : "");
 define('TABLE_CSV_SEP',nb::p('sep') ? nb::p('sep') : "\t");
 
-#if (!defined('DB_HTML_BUTTON_SUBMIT')) define('DB_HTML_BUTTON_SUBMIT','<input type="submit" class="button" value="GO"/>');
-#if (!defined('DB_HTML_BUTTON_ADD'))    define('DB_HTML_BUTTON_ADD','<a class="button" href="?" onclick="nb.form_clear(this.parentElement) ? 0: 0">Add</a>');
-#if (!defined('DB_HTML_BUTTON_ADD'))    define('DB_HTML_BUTTON_ADD','<input type="submit" class="button" value="Add" onclick="this.setAttribute(\'name\',\'edit\')?0:0"/>');
 if (!defined('DB_HTML_EDIT')) define('DB_HTML_EDIT','Edit');
 if (!defined('DB_HTML_DELETE')) define('DB_HTML_DELETE','Delete');
 
@@ -275,7 +271,7 @@ Class Table extends nb {
       $this->fields = [];
 
       $conf = $this->unvar($this->db()->conf_type('table.fields',true));
-      if (is_scalar($conf)) $conf = array('sql'=>$conf);
+      if (is_scalar($conf)) $conf = ['sql'=>$conf];
       $rows = $this->db()->conn->query($conf['sql']);
 
       $rows->setFetchMode(PDO::FETCH_ASSOC);
@@ -307,7 +303,7 @@ Class Table extends nb {
 
         if (isset($conf['fct'])) $conf['fct']($row) ;
 
-        $field = array(
+        $field = [
           'table'         => $this,
           'name'          => $row['name'],
           'type'          => strtolower($row['type']),
@@ -316,7 +312,8 @@ Class Table extends nb {
           'null'          => (preg_match('/^(f.*|no|0)?\s*$/i',$row['null']) ? 0 : 1),
           'extra'         => (isset($row['extra']) ? $row['extra'] : null), # !!! nothing todo with array $extra, this info from the sql server
           'autoincrement' => (isset($row['autoincrement']) ? $row['autoincrement'] : 0),
-        );
+        ];
+
         if (isset($row['uniq'])) $field['uniq'] = $row['uniq'];
         if (isset($row['default'])) $field['default'] = $row['default'];
 
@@ -340,9 +337,9 @@ Class Table extends nb {
     return $this->fields;
   }
 
-  public function url_keys($values=null,$params=array(),$sep='&amp;') {
+  public function url_keys($values=null,$params=[],$sep='&amp;') {
     if ($values === null) $values = $this->p();
-    $url = is_array($params) ? $params : array($params);
+    $url = is_array($params) ? $params : [$params];
 
     $keys = $this->fields_keys($others);
     if (empty($keys)) $keys = $others;
@@ -358,9 +355,9 @@ Class Table extends nb {
     return $url ? '?'.join($sep,$url) : '';
   }
 
-  public function fields_keys(&$others=array()) {
+  public function fields_keys(&$others=[]) {
 
-    $fields_keys = array();
+    $fields_keys = [];
 
     foreach ($this->fields() as $name => $f) {
       if ($f->key) {
@@ -374,7 +371,7 @@ Class Table extends nb {
 
   }
 
-  public static function form_hidden($ignore=array()) {
+  public static function form_hidden($ignore=[]) {
     $h = '';
     foreach (array_diff(self::$params,$ignore) as $p) {
       if ($v=self::p($p)) {
@@ -387,7 +384,7 @@ Class Table extends nb {
 
   public function html_edit($values = null) {
     if ($values === null) $values = $this->p();
-    if (!is_array($values)) $values = array($values);
+    if (!is_array($values)) $values = [$values];
     $fields = array_filter($this->fields(),function($v){return empty($v->extra);});
     #$fields = $this->fields();
     #debug($fields);
@@ -440,7 +437,7 @@ Class Table extends nb {
 
     echo ''
       .'<input type="hidden" name="action" value="'.($add ? 'insert' : 'update').'"/>'
-      .self::form_hidden(array('action','HTTP_REFERER'))
+      .self::form_hidden(['action','HTTP_REFERER'])
       .(!empty($_SERVER['HTTP_REFERER']) ? '<input type="hidden" name="referer" value="'.urlencode($_SERVER['HTTP_REFERER']).'" />' : '')
     .'</form>'.NB_EOL;
 
@@ -448,10 +445,10 @@ Class Table extends nb {
 
   public function url_list($k='',$v='') {
 
-    $params = array();
-    $fields = ($this->p('action') == 'delete') ? array() : $this->fields();
+    $params = [];
+    $fields = ($this->p('action') == 'delete') ? [] : $this->fields();
 
-    foreach ( array_diff( array_merge(self::$params,array_keys($fields)), array('action') ) as $f) {
+    foreach ( array_diff( array_merge(self::$params,array_keys($fields)), ['action'] ) as $f) {
 
       if (strcmp($this->p($f,''),'')==0) continue;
       $params[$f] = $this->p($f);
@@ -469,7 +466,7 @@ Class Table extends nb {
     }
 
 # NB 03.04.16     if ($this->p('db')) $params['db'] = $this->p('db');
-    $flat = array();
+    $flat = [];
     foreach ($params as $k=>$v) { $flat[] = $k.'='.urlencode($v); }
     return $flat ? '?'. join('&amp;',$flat) : ''; 
 
@@ -511,7 +508,7 @@ Class Table extends nb {
     if ($count<$tot) {
       list($x,$y) = strpos($limit,',')!==false
         ? preg_split('/\s*,\s*/',$limit)
-        : array(0,$limit)
+        : [0,$limit]
       ;
 
       $prev = $x - $y;
@@ -539,7 +536,7 @@ Class Table extends nb {
   public function where($fields,$hvalues,$need_all_values=false) {
 
     // Construct where
-    $where = array();
+    $where = [];
     foreach ($fields as $k => $field) {
       if (!isset($hvalues[$k])) {
         if ($need_all_values) return null;
@@ -547,15 +544,13 @@ Class Table extends nb {
       }
       $where[] = $field->sql_name() . '=' . $field->quote($hvalues[$k]);
     }
-    #var_dump($where); exit;
-      #.' VALUES (' . join(',',ar_map('":$a"',$fields)).')'
 
     return empty($where) ? '' : ' WHERE ' . join(' AND ',$where);
 
   }
 
   public function where_criterias($values,$logic='') {
-    $having = $where = array();
+    $having = $where = [];
     if (empty($logic)) $logic = 'AND';
 
     $regexp = $this->db()->conf_type('regexp');
@@ -662,11 +657,11 @@ Class Table extends nb {
         continue;
       }
 
-      $v = new Field( ( is_array($v) ? $v : array() ) + array(
+      $v = new Field( ( is_array($v) ? $v : [] ) + [
         'name' => $k,
         'type' => 'text',
         'extras' => $v,
-      ));
+      ]);
 
       $this->fields[$k] = $v;
       $this->extras[$k] = $v;
@@ -690,7 +685,7 @@ Class Table extends nb {
   /******************************************************************
     Html Output
   ******************************************************************/
-  public function rows_sql(&$opt=array()) {
+  public function rows_sql(&$opt=[]) {
 
     if (isset($this->orderby)) self::pdef('orderby',$this->orderby);
     if (self::p('order')) self::pset('orderby',self::p('orderby').' '.self::p('order')); # from Wordpress
@@ -709,14 +704,14 @@ Class Table extends nb {
 
       $where = $this->where_criterias($this->p(),$this->p('op'));
       $select_count = ( $where ? $this->db()->conf_type('select_count') : null );
-      if (empty($select_count)) $select_count = array('','');
+      if (empty($select_count)) $select_count = ['',''];
 
       if (!empty($this->_rows_fields)) {
         foreach ($this->fields() as $f) {
           if (empty($f->extra)) $select_fields[] = $f->sql_name();
         }
       } else {
-        $select_fields = array('*');
+        $select_fields = ['*'];
       }
 
       $sql = "SELECT ".trim( $select_count[0].' '.join(',',$select_fields) ). $this->select_extras();
@@ -741,7 +736,7 @@ Class Table extends nb {
 # NB 28.03.16     $this->sql = $sql;
     $this->debug(preg_replace('/[\r\n]+[ ]*/',' ',$sql),1);
 # NB 03.09.16     $this->debug(preg_replace('/(,|FROM|WHERE|HAVING|GROUP|ORDER)/i',"\n\\1",$sql),1);
-    return array($sql,$where,$limit,$select_count);
+    return [$sql,$where,$limit,$select_count];
   }
 
   public function buttons() {
@@ -975,11 +970,11 @@ Class Table extends nb {
 
     $limit = preg_replace('/^.*,\s*/','',$this->limit);
 
-    $this->_html_table->set_pagination_args(array(
+    $this->_html_table->set_pagination_args([
       'total_items' => $this->tot, // total items defined above
       'per_page' => $limit, // per page constant defined at top of method
       'total_pages' => ceil($this->tot / $limit) // calculate pages count
-    ));
+    ]);
 
     #$this->_html_table->display_tablenav('top');
     $this->_html_table->display();
@@ -997,7 +992,7 @@ Class Table extends nb {
   }
 
   public function rows_rec_sql(&$row,&$opt) {
-    $keys = $values = array();
+    $keys = $values = [];
 
     foreach ($row as $k=>$v) {
       if (isset($this->extras[$k])) continue;
@@ -1165,7 +1160,7 @@ Class Table extends nb {
     return $html;
   }
 
-  public function rows_end_table($opt=array()) {
+  public function rows_end_table($opt=[]) {
     $html = '';
     $html .= '</tbody>'.NB_EOL;
     $html .= '</table>'.NB_EOL;
@@ -1203,7 +1198,7 @@ Class Table extends nb {
     return $html;
   }
 
-  public function rows_end_div($opt=array()) {
+  public function rows_end_div($opt=[]) {
     return '</div>'.NB_EOL;
   }
 
@@ -1211,15 +1206,15 @@ Class Table extends nb {
     return $this->db()->sql_name($value === null ? $this->name : $value);
   }
 
-  public function replace($hvalues,&$info=array()) {
+  public function replace($hvalues,&$info=[]) {
     return $this->insert($hvalues,$info,'REPLACE');
   }
 
-  public function insert($hvalues,&$info=array(),$insert_word='INSERT') {
-    if (empty($info['values'])) $info['values'] = array();
+  public function insert($hvalues,&$info=[],$insert_word='INSERT') {
+    if (empty($info['values'])) $info['values'] = [];
     $info['values'] = $hvalues;
 
-    $sql_names = $fields = $values = array();
+    $sql_names = $fields = $values = [];
 
     foreach ($this->fields() as $name => $field) {
       if (!isset($hvalues[$name])) continue;
@@ -1268,17 +1263,17 @@ Class Table extends nb {
   }
 
   # dbq t=nb.mime_type a=table.update type=application/rss+xml name='RSS - Really Simple Syndication' ext=rss debug=2
-  public function update($hvalues,&$info=array()) {
-    if (empty($info['values'])) $info['values'] = array();
+  public function update($hvalues,&$info=[]) {
+    if (empty($info['values'])) $info['values'] = [];
     $info['values'] = $hvalues;
 
-    $keys = array();
-    $keys_values = array();
-    $fields = array();
-    $fields_values = array();
+    $keys = [];
+    $keys_values = [];
+    $fields = [];
+    $fields_values = [];
 
-    #$update = array();
-    #$where = array();
+    #$update = [];
+    #$where = [];
 
     foreach ($this->fields() as $name => $field) {
 
@@ -1351,8 +1346,8 @@ Class Table extends nb {
 
   }
 
-  public function delete($hvalues,&$info=array()) {
-    if (empty($info['values'])) $info['values'] = array();
+  public function delete($hvalues,&$info=[]) {
+    if (empty($info['values'])) $info['values'] = [];
     $info['values'] = $hvalues;
 
     $keys = $this->fields_keys();
@@ -1378,7 +1373,7 @@ Class Table extends nb {
     return $info['rowCount'];
   }
 
-  public function out($v,$head=array()) { return $this->db()->out($v,$head); }
+  public function out($v,$head=[]) { return $this->db()->out($v,$head); }
 
   private function url_referer($default='') {
     if (self::p('referer')) {
@@ -1458,7 +1453,7 @@ Class Table extends nb {
 
     } elseif ($this->p('format') and !preg_match('/^(table|div)$/',$this->p('format'))) {
 
-      $this->rows($dummy,array('format' => $this->p('format')));
+      $this->rows($dummy,['format' => $this->p('format')]);
       return true;
 
     } elseif ($action == 'edit') {
@@ -1477,13 +1472,13 @@ Class Table extends nb {
   }
 
   public function html_row_buttons(&$row) {
-    return array(
+    return [
       '<a class="edit button" href="'.$this->url_keys($row,'action=edit').'">'.DB_HTML_EDIT.'</a>'.NB_EOL,
       '<a class="delete button" href="'.$this->url_keys($row,'action=delete')
         .'&amp;referer='
         .( isset($_SERVER['REQUEST_URI']) ? urlencode($_SERVER['REQUEST_URI']) : '' )
       .'">'.DB_HTML_DELETE.'</a>'.NB_EOL,
-    );
+    ];
   }
 
   public function html_rows_top() {
@@ -1492,7 +1487,7 @@ Class Table extends nb {
 
     if (!empty($this->replace)) {
 
-      $replace = array();
+      $replace = [];
       foreach ($this->replace as $k=>$v) { $replace[] = "$k.$v"; }
       $html .= '<span id="db-table-replace" style="display:none">'.join(' ',$replace).'</span>'.NB_EOL;
 
@@ -1542,50 +1537,50 @@ Class Table extends nb {
       $r .= '<div class="options">';
 
       // Hiddens
-      $r .= self::form_hidden(array('db','table','format','limit','download'));
+      $r .= self::form_hidden(['db','table','format','limit','download']);
       $r .= '<input type="hidden" name="download" value="0"/>'; // Embed for no html format
 
       // Tables - see default.js if you change class
       $r .= '<span class="label">';
-      $r .= '<label for="table">Tables</label>'.html_select_array(array_keys($this->db()->tables()),array(
+      $r .= '<label for="table">Tables</label>'.html_select_array(array_keys($this->db()->tables()),[
         'html'       => 'class="tables" name="table" id="table"',
         'selected'   => $this->p('table'),
         'prettyText' => true,
         'sort' => 'natcasesort',
-      ));
+      ]);
       $r .= '</span>';
 
       // Dbs - see default.js if you change class
       if (!empty($this->db()->dbs) and count($this->db()->dbs)>1) {
         $r .= '<span class="label">';
-        $r .= '<label for="db">Db</label>'.html_select_array($this->db()->dbs,array(
+        $r .= '<label for="db">Db</label>'.html_select_array($this->db()->dbs,[
           'html'       => 'class="dbs" id="db" name="db" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"',
           'selected'   => self::p('db'),
           'prettyText' => true,
           'sort' => 'natcasesort',
-        ));
+        ]);
         $r .= '</span>';
       }
 
       // Format
       $r .= '<span class="label">';
 
-      $r .= '<label for="format">Format</label>'.html_select_array($this->db()->formats,array(
+      $r .= '<label for="format">Format</label>'.html_select_array($this->db()->formats,[
         'html'       => 'class="format" name="format" id="format"',
         'selected'   => $this->p('format'),
         'prettyText' => true,
         'sort' => 'natcasesort',
-      ));
+      ]);
       $r .= '</span>';
 
       // Limit
       if (!empty($this->db()->limits)) {
         $r .= '<span class="label">';
-        $r .= '<label for="limit">Limit</label>'.html_select_array($this->db()->limits,array(
+        $r .= '<label for="limit">Limit</label>'.html_select_array($this->db()->limits,[
           'html'       => 'class="limit" name="limit" id="limit"',
           'selected'   => $this->p('limit'),
           'prettyText' => true,
-        ));
+        ]);
         $r .= '</span>';
       }
 
@@ -1595,11 +1590,11 @@ Class Table extends nb {
       // Order By
       /*
       $r .= '<span class="label">';
-      $r .= '<label for="limit">OrderBy</label>'.html_select_array(array_keys($this->fields()),array(
+      $r .= '<label for="limit">OrderBy</label>'.html_select_array(array_keys($this->fields()),[
         'html'       => 'class="orderby" name="orderby" id="orderby"',
         'selected'   => $this->p('orderby'),
         'prettyText' => true,
-      ));
+      ]);
       $r .= '</span>';
       */
 
@@ -1642,7 +1637,7 @@ Class Table extends nb {
   }
 
   public function __sleep() {
-    return array(
+    return [
       'name',
       'sql',
       'type',
@@ -1653,7 +1648,7 @@ Class Table extends nb {
       'count',
       'engine',
       'created',
-    );
+    ];
   }
 
   public function serialize() {
@@ -1722,7 +1717,6 @@ Class Table extends nb {
       }
     }
 
-    #$key = 'count';
     # Params
     foreach ([
       'count',
@@ -1737,15 +1731,11 @@ Class Table extends nb {
         if ($k!=$key) continue;
       }
 
-      # No count for view
-      #if ($k == 'count' and $this->type != 'table') continue;
-
       $this->status[$k] = $this->$k();
       if (is_array($this->status[$k])) $this->status[$k] = count($this->status[$k]);
     }
 
     if (!empty($key)) return ( empty($this->status[$key]) ? '' : $this->status[$key] );
-#debug($this->name.'='.$this->type);
     return $this->status;
   }
 
index 771024af5e84497cdccb8813e08ba08f3d77d51a..48d95ac3cfbc738ab13654f04086598589160dcd 100644 (file)
@@ -21,7 +21,6 @@ $DB_TYPES['sqlite'] = array (
 },
 'databases' => [
   'PRAGMA database_list',function(&$r) {
-#debug($GLOBALS['Db']->databases());
     if (empty($r['file'])) $r = null;;
     unset($r['seq']);
   },
index 64508bf149a32458e2b8de17c39ab4bb05b5109f..4fb4af40162afdc0f137711408ad98bc8e0bc7d8 100644 (file)
@@ -788,14 +788,17 @@ class NB {
 
   public static function array_fill_assoc($rows) {
     $keys = [];
+
     foreach($rows as $k=>$v) {
       $keys = array_merge_recursive(array_keys($v),$keys);
     }
+
     foreach($rows as $k=>$v) {
       foreach ($keys as $key) {
         if (empty($v[$key])) $rows[$k][$key] = '';
       }
     }
+
     return $rows;
   }
 
index e27128918698441dd27d5ab08cd94466cc580ade..07f9798bab81da797f71b6808d7e67ecbc20e07e 100644 (file)
@@ -1,12 +1,15 @@
 php:
   build: ../../php/
   volumes:
-    - ./../../../:/opt/nb
+    #- ./../../../..:/opt/nb
+    - ./../../../../..:/opt
+    - ./../../../../lib/php/db:/var/www/html
   expose:
     - 9000
 
 nginx:
   build: ../../nginx/
+  #image: nginx:latest
   ports:
     - 80:80
   links:
diff --git a/src/Docker/Compose/up.sh b/src/Docker/Compose/up.sh
new file mode 100644 (file)
index 0000000..0d328c1
--- /dev/null
@@ -0,0 +1 @@
+docker-compose up --force-recreate --build --remove-orphans -d
index e085cd6110f5033f75e0e9d14386af1eb9a26ce8..d5d804b5cdeb30b032924420b348575c3c77ed41 100644 (file)
@@ -1,2 +1,3 @@
 FROM nginx:latest
 COPY ./default.conf /etc/nginx/conf.d/default.conf
+CMD nginx -g 'daemon off;'
index cafc9402d0f77a2d836cd855fe7e6922b69c1624..a3f65d0b1bbb4dc95d6c95dc9ce5101d0798329c 100644 (file)
@@ -5,6 +5,8 @@ FROM php:7.0-fpm-alpine
 #RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
 RUN set -ex && apk --no-cache add postgresql-dev
 RUN docker-php-ext-install pdo pdo_mysql pdo_sqlite pdo_sqlite pdo_pgsql pgsql
+RUN mkdir /opt
 
 EXPOSE 9000
-CMD ["/usr/bin/php", "-a"]
+#CMD ["/usr/local/bin/php", "-a"]
+CMD /usr/local/sbin/php-fpm