From d26f6f08cdcd2953c5f351f99a2bf2430d4b6555 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 12 Jan 2018 06:21:36 +0000 Subject: [PATCH] lib/php/db/table.php --- etc/profile.d/git.sh | 7 ++++--- lib/php/db/field.php | 3 ++- lib/php/db/table.php | 8 ++++++-- lib/php/out.php | 12 ++++++------ www/dbq/dbq.php | 3 ++- www/dbq/etc/nginx.conf | 3 +++ 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/etc/profile.d/git.sh b/etc/profile.d/git.sh index 1f3a7073..78743660 100644 --- a/etc/profile.d/git.sh +++ b/etc/profile.d/git.sh @@ -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 ', ' ) } diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 28655d34..347fc424 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -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); } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 65c7a25a..e50af7d7 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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())); diff --git a/lib/php/out.php b/lib/php/out.php index d7f4c2b8..db6b7384 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -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--; diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 9925966b..def4714d 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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 diff --git a/www/dbq/etc/nginx.conf b/www/dbq/etc/nginx.conf index 95c85757..b32adcf9 100644 --- a/www/dbq/etc/nginx.conf +++ b/www/dbq/etc/nginx.conf @@ -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; } -- 2.47.3