]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/table.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 12 Jan 2018 06:21:36 +0000 (06:21 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 12 Jan 2018 06:21:36 +0000 (06:21 +0000)
etc/profile.d/git.sh
lib/php/db/field.php
lib/php/db/table.php
lib/php/out.php
www/dbq/dbq.php
www/dbq/etc/nginx.conf

index 1f3a707398b342ac4baaf73fe071be270e9d4d19..787436608a463570bba15b8bf514106ab98aefab 100644 (file)
@@ -223,7 +223,8 @@ objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort
 
 echo "All sizes are in kB. The pack column is the size of the object, compressed, inside the pack file."
 
-output="size,pack,SHA,location"
+(
+echo "size,pack,SHA,location"
 for y in $objects
 do
        # extract the size in bytes
@@ -235,10 +236,10 @@ do
        # find the objects location in the repository tree
        other=`git rev-list --all --objects | grep $sha`
        #lineBreak=`echo -e "\n"`
-       output="${output}\n${size},${compressedSize},${other}"
+       echo "${size},${compressedSize},${other}"
 done
+) | column -t -s ', '
 
-echo -e $output | column -t -s ', '
 )
 }
 
index 28655d348b451758b3496ae1e8d1299d566b6c98..347fc424d700dfce1fb23a20c17442a0bd40c4a6 100644 (file)
@@ -150,7 +150,8 @@ class field extends nb {
     return $this->db()->cast_text($name);
   }
 
-  public function sql_name() {
+  public function sql_name(bool $cast=false) {
+               if ($cast and !$this->text()) return $this->sql_name_cast_text();
     return $this->db()->sql_name($this->name);
   }
 
index 65c7a25a6a62b1ceff83cf05475e02866b3f1aab..e50af7d7dae24a0c383a25a02bc9576a1d4d3994 100644 (file)
@@ -804,8 +804,8 @@ Class Table extends nb {
 
       }
 
-                       $name = $field->sql_name();
-                       if (!$field->text()) $name = $field->sql_name_cast_text();
+                       $name = $field->sql_name(true);
+# NB 12.01.18                  if (!$field->text()) $name = $field->sql_name_cast_text();
 
       if ($field->extras) {
         $k = $this->extras[$k]->sql_name();
@@ -1888,6 +1888,10 @@ Class Table extends nb {
 
   }
 
+  public function maxlengths() {
+# NB 12.01.18     $sql = 'MAX(LENGTH('.$field->sql_name(true).'))';
+       }
+
   public function fields_rows() {
     $rows = array_values($this->object2array($this->fields()));
 
index d7f4c2b898bdec87f0de720e9dfd2dda5a9fa420..db6b7384429a07a86289d63d01234968a731ac9a 100644 (file)
@@ -539,7 +539,7 @@ Class Out extends Nb {
       $o['_human']['eol'] = $o['eol'];
       $o['eol'] = "";
 
-      $o['tmpfile'] = tmpfile();
+      $o['_human']['tmpfile'] = tmpfile();
 
       # no csv echo call
       $o['return'] = true;
@@ -562,18 +562,18 @@ Class Out extends Nb {
       $i++;
     }
 
-    if (!isset($o['tmpfile'])) {
+    if (!isset($o['_human']['tmpfile'])) {
       echo "\n";
       self::bye("Option tmpfile is missing, wrong uage of this funtion!");
     }
 
-    fwrite($o['tmpfile'],$line."\n");
+    fwrite($o['_human']['tmpfile'],$line."\n");
 
   }
 
   public static function out_human_end(&$o) {
     $len = $o['_human']['len'];
-    fseek($o['tmpfile'], 0);
+    fseek($o['_human']['tmpfile'], 0);
 
     $sep_line = '';
     if (self::p('sep_line') !== '0') {
@@ -586,7 +586,7 @@ Class Out extends Nb {
 
     $header = empty($o['_human']['head']) ? 0 : 1;
     $count = 0;
-    while (($line = fgets($o['tmpfile'])) !== false) {
+    while (($line = fgets($o['_human']['tmpfile'])) !== false) {
 
       $values = [];
       $i = 0;
@@ -608,7 +608,7 @@ Class Out extends Nb {
       $count++;
     }
 
-    fclose($o['tmpfile']);
+    fclose($o['_human']['tmpfile']);
     unset($o['_human']);
 
     if ($header) $count--;
index 9925966b28e95801492626c4853c28645525cfdb..def4714d263dc518962421faeef8a1fea9d6e90f 100644 (file)
@@ -107,11 +107,12 @@ class DbQ extends nb {
                        'css',
                        'js',
                        'format_html_ua_exp',
+                       'format_cli',
                        'expires',
                ] as $k) {
                        $env = 'DBQ_'.strtoupper($k);
 
-                       if (isset($_SERVER[$env])) $this->$k = $_SERVER[$env];
+                       if (isset($_SERVER[$env]) and $_SERVER[$env] !="") $this->$k = $_SERVER[$env];
                }
 
                // Envs -> params
index 95c85757b16792a9738bf17745455ccb968833a8..b32adcf936d66d24d60b5ff210dc64d7caa59f1c 100644 (file)
@@ -55,4 +55,7 @@ location ~ /index\.php$ {
 
        if ($DBQ_EXPIRES = "") { set $DBQ_EXPIRES ""; }
        fastcgi_param DBQ_EXPIRES $DBQ_EXPIRES;
+
+       if ($DBQ_FORMAT_CLI = "") { set $DBQ_FORMAT_CLI ""; }
+       fastcgi_param DBQ_FORMAT_CLI $DBQ_FORMAT_CLI;
 }