From cf0dee62e2f9b45ecfb7491ef746408e159b508f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 6 Sep 2016 01:03:45 +0100 Subject: [PATCH] Bed --- bin/dbq | 11 ++++++----- lib/php/db.php | 4 +++- lib/php/db/table.php | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/dbq b/bin/dbq index 402fb84c..6267b5ba 100755 --- a/bin/dbq +++ b/bin/dbq @@ -28,10 +28,11 @@ my $VERSION = '0.0.1'; my ($NAME) = $0 =~ m,([^/]+)$,; my $UC_NAME = uc($NAME); my %PARAM = ( - 'format' => $ENV{$UC_NAME.'_FORMAT'} ? $ENV{$UC_NAME.'_FORMAT'} : 'nc', + 'format' => $ENV{$UC_NAME.'_FORMAT'} ? $ENV{$UC_NAME.'_FORMAT'} : 'human', # NB 09.04.16 'action' => $ENV{$UC_NAME.'_PARAM'} ? $ENV{$UC_NAME.'_PARAM'} : 'rows', # NB 13.04.16 'db' => $ENV{$UC_NAME.'_DB'} ? $ENV{$UC_NAME.'_DB'} : '', 'txt_errors' => $ENV{$UC_NAME.'_TXT_ERRORS'} ? $ENV{$UC_NAME.'_TXT_ERRORS'} : '1', + 'rows_head_char' => "\r", ); $PARAM{'format'} = 'csv' unless -t STDOUT; @@ -45,9 +46,9 @@ if ($ENV{$UC_NAME.'_PARAMS'}) { my %CMD_ALIASE = ( # NB 09.04.16 'd' => 'db', # NB 09.04.16 't' => 'table', - 'f' => 'format', - 'o' => 'format', - 'out' => 'format', +# NB 06.09.16 'f' => 'format', +# NB 06.09.16 'o' => 'format', +# NB 06.09.16 'out' => 'format', # NB 09.04.16 'l' => 'limit', # NB 09.04.16 'a' => 'action', # NB 09.04.16 'h' => 'header', @@ -279,7 +280,7 @@ sub csv2txt { my $count=0; for (@lines) { my @F = @$_; - last if $count and @F and $F[0] =~/^\r/; + last if $count and @F and $F[0] =~/$PARAM{'rows_head_char'}/; $count++; for (my $i=0;$i<@F;$i++) { diff --git a/lib/php/db.php b/lib/php/db.php index 1e4953a3..b8d7620c 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -902,11 +902,13 @@ class Db extends nb { self::paliases([ 'd' => 'db', 't' => 'table', - 'f' => 'format', 'l' => 'limit', 'a' => 'action', 'h' => 'header', + + 'f' => 'format', 'out' => 'format', + 'o' => 'format', ]); if ($action=self::p('action')) { diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 37b2ea96..30b4ef04 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1079,8 +1079,9 @@ Class Table extends nb { -----------------------------------------------------------------*/ public function rows_begin_csv($fields) { + if (self::p('rows_head_char')!=='') echo self::p('rows_head_char'); if ($this->p('header')==="0") return ''; - return "\r".join(TABLE_CSV_SEP,array_keys($fields))."\n"; + return join(TABLE_CSV_SEP,array_keys($fields))."\n"; } public function rows_rec_csv(&$row) { -- 2.47.3