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);
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)) {
$this->fields = array();
$conf = str_replace('<NAME>',$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);
$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();