From 741aed96142b848610ba71234af90a25f202960f Mon Sep 17 00:00:00 2001 From: Devops Date: Thu, 6 Apr 2017 15:15:30 +0100 Subject: [PATCH] lib/php/db/table.php --- lib/php/db.php | 20 -------------------- lib/php/db/table.php | 26 ++++++++++---------------- lib/php/out.php | 16 +--------------- www/dbq/dbq.php | 1 - 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index f250393f..ac1a6bcc 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -171,32 +171,12 @@ class Db extends nb { if (!isset($opt['format'])) { if ($this->out->client_type()) $this->format = $this->out->client_type(); if (self::p('format')) $this->format = self::p('format'); - # NB 05.12.16: Should be the single point for caling ::p() - #$this->format = self::p('format'); } - # Add formats from module out -# NB 23.12.16 foreach($this->out->types('_web_') as $t=>$v) if (!in_array($t,$this->formats)) $this->formats[] = $t; - # Pdo $this->connect_init(); if ($connect) $this->connect(); - # Params - /* - if (empty($this->limit) and !empty($this->limits)) { - $this->limit = $this->limits[0]; - } - if (empty($this->limit)) { - if ($this->p('paged')) { - $this->limit = ($this->limit * $this->p('paged')).','.$this->limit; - } elseif ($this->limit=$this->p('limit')) { - } else { - $this->limit = $this->limits[0]; - } - } - */ - # Extras must disapear - NB 29.03.16 if (!empty($this->extras)) self::bye($this->extras); return true; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 71a0065f..8fcdac86 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -105,10 +105,16 @@ Class Table extends nb { } # NB 22.12.16: TODEL - $this->show_header = (bool)$this->p('header',$this->show_header); + #$this->show_header = (bool)$this->p('header',$this->show_header); + #$this->pdef('header',$this->show_header); - # TODEL WHEN NOT NEEDED ???? + if (isset($_GET['rows.header'])) $this->show_header = $_GET['rows.header']; + $this->show_header = (bool)$this->p('header',$this->show_header); $this->pdef('header',$this->show_header); + + # TODO no more pdef !!! + #$this->db()->out->header($this->show_header); + #debug($this->db()->out->header()); #bye((int)$this->show_header); } @@ -145,11 +151,10 @@ Class Table extends nb { $this->_fields = 1; foreach ($this->rows as $row) { + foreach ($row as $k=>$v) { $field = $this->fields($k); - #debug("$v:$k"); $field->bindParam($query,$v,":$k"); - #$query->bindParam($k, $v, $this->type2pdo('text')); } if (!($execute = $query->execute())) { @@ -959,20 +964,11 @@ Class Table extends nb { } public function rows(&$opt=[],$opt_by_val=null) { -# NB 25.12.16 if (empty($this->db()->limit)) { -# NB 25.12.16 $this->db()->limit = $this->db()->limits[0]; -# NB 25.12.16 } - # # Run query # $this->create_temporary(); - $this->show_header = (bool)$this->p('rows.header',$this->show_header); - $this->db()->out->header($this->show_header); - # TODEL WHEN NOT NEEDED ???? - $this->pdef('header',$this->show_header); - if ($opt_by_val !== null) $opt = $opt_by_val; #if (isset($opt['format']) and empty($opt['format'])) { @@ -1045,7 +1041,6 @@ Class Table extends nb { : false ; -#debug($this->db()->name); if ($opt['is_html'] and !empty(self::$params) and !$this->p('action') and !$this->p('inc')) { echo $this->html_menu($opt); } @@ -2041,8 +2036,7 @@ Class Table extends nb { $r .= '' .'' - . '' + . '' . '' .'' ; diff --git a/lib/php/out.php b/lib/php/out.php index 8bc0fa31..0f3ce065 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -78,20 +78,6 @@ Class Out extends Nb { } ], - # NB 01.04.17: Stil used, sh should be enought -# NB 01.04.17 'shell' => [ -# NB 01.04.17 'preff' => self::p('preff',''), -# NB 01.04.17 'suff' => self::p('suff',''), -# NB 01.04.17 'row' => function(&$o,&$r) { -# NB 01.04.17 $line = []; -# NB 01.04.17 foreach ($r as $k=>$v) { -# NB 01.04.17 $v = str_replace('"','\\"',$v); -# NB 01.04.17 $line[] = $o['preff']."$k=\"$v\"".$o['suff']; -# NB 01.04.17 } -# NB 01.04.17 if ($line) echo join(' ',$line)."\n"; -# NB 01.04.17 } -# NB 01.04.17 ], - 'sh' => array( 'preff' => self::p('preff',""), 'row' => function(&$o,&$r) { @@ -560,7 +546,7 @@ Class Out extends Nb { if (!empty($o['quote'])) $v = $o['quote'] . str_replace($o['quote'],$o['quote_escape'].$o['quote'],$v) . $o['quote']; - $values[] = str_replace("\n",'\\n',self::scalar($v)); + $values[] = str_replace("\n",'\\n',str_replace("\r","",self::scalar($v))); } if (!empty($o['return'])) return join($o['sep'],$values); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index f5b314cc..a3bd7608 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -211,7 +211,6 @@ class DbQ extends nb { $connect['id'] = $this->params['db']; $this->db->__construct($connect); - #$this->id = $this->params['db']; $this->db->connect(); $this->db->base = '/'.$this->db->id; return $this->db; -- 2.47.3