From 74e2188e16eefaa37f69071799d8f49258573604 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 6 Apr 2016 17:49:08 +0200 Subject: [PATCH] putr back create table --- lib/php/db.php | 3 +++ lib/php/db/table.php | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index cf32676c..ec39dfc6 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -703,6 +703,9 @@ EOF; public function fields($st) { # See: http://php.net/manual/en/pdostatement.getcolumnmeta.php $fields = array(); + #debug($st->columnCount()); + #debug($st->getColumnMeta(0)); + for ($i = 0; $i < $st->columnCount(); $i++) { $col = $st->getColumnMeta($i); diff --git a/lib/php/db/table.php b/lib/php/db/table.php index c8104592..b5ef096b 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -82,11 +82,11 @@ Class Table extends nb { foreach ($opt as $k => $v) { $this->$k = $v; } // Name, could be a select - if (0 and stripos($this->name,'SELECT ')===0) { + if (DB_TABLE_QUERY_NAME and stripos($this->name,'SELECT ')===0) { #$temp = '_'.substr(md5($this->name),0,6); $temp = DB_TABLE_QUERY_NAME; #bye("CREATE TEMPORARY VIEW $temp AS $this->name"); - $this->db()->conn->query("CREATE TEMPORARY TABLE $temp AS $this->name"); + $this->db()->conn->query("CREATE TEMPORARY VIEW $temp AS $this->name"); $this->name = $temp; } elseif (preg_match('/\b(\.import|LOAD DATA|COPY|INSERT|REPLACE|DELETE|TRUNCATE|CREATE|DROP|ALERT)\b/',$this->name)) { @@ -162,6 +162,7 @@ Class Table extends nb { $this->fields = array(); $conf = str_replace('',$this->name,$this->db()->type('table.fields',true)); if (is_scalar($conf)) $conf = array('sql'=>$conf); + #debug($conf); $rows = $this->db()->conn->query($conf['sql']); $rows->setFetchMode(PDO::FETCH_ASSOC); @@ -586,9 +587,11 @@ Class Table extends nb { $st->execute(); # Fields - $fields = array(); - foreach ($this->db()->fields($st) as $f) { $fields[$f->name] = $f; } - $this->fields = $fields; + if (!DB_TABLE_QUERY_NAME) { + $fields = array(); + foreach ($this->db()->fields($st) as $f) { $fields[$f->name] = $f; } + $this->fields = $fields; + } #debug($fields); #bye($this->name); if (!$this->p('action')) echo $this->html_menu(); -- 2.47.3