foreach ($this->conn->query($sql,PDO::FETCH_ASSOC) as $row) {
#debug($row);
$name = current($row);
- $t = $this->table($name,$row);
+ $t = $this->table($name,$row+['status'=>$row]);
}
}
if (!empty($count) and !$this->str_match($t->count,$count)) continue;
if (!empty($engine) and !$this->str_match($t->engine,$engine)) continue;
- $rows[] = []
- +[
- 'name' => $t->name,
- 'type' => $t->type,
- ]
- +$t->infos()
- +( self::p('fields') ?['fields' => count($t->fields())] : [] )
- +( self::p('count') ?['count' => $t->count()] : [] )
- +( self::p('sql') ? ['sql' => $t->sql()] : [] )
- ;
+ $rows[] = $t->status();
}
usort($rows,function($a,$b) { return strcmp($a['name'],$b['name']); });
public function out($v,$head=array()) { return $this->db()->out($v,$head); }
public function infos() {
+ return ['TODEL'];
+ # TODEL - NB 07.09.16
$this->type();
return
- array(
+ [
"name" => $this->name,
"type" => $this->type,
#"fields" => count($this->fields()),
#"count" => $this->count(),
#"sql_name" => $this->sql_name(),
- )
- +( isset($this->engine) ? array("engine" => $this->engine) : array() )
- +( isset($this->created) ? array("created" => $this->created) : array() )
+ ]
+ +( isset($this->engine) ? ["engine" => $this->engine] : [] )
+ +( isset($this->created) ? ["created" => $this->created] : [] )
+# NB 07.09.16 +( self::p('fields') ?['fields' => count($this->fields())] : [] )
+# NB 07.09.16 +( self::p('count') ?['count' => $this->count()] : [] )
+# NB 07.09.16 +( self::p('sql') ? ['sql' => $this->sql()] : [] )
;
}
#$sql .= ' AND name='.$this->db()->quote($this->name);
$sql = "SELECT * FROM ($sql) t WHERE name=".$this->db()->quote($this->name);
- $this->status = $this->db()->conn->query($sql,PDO::FETCH_ASSOC);
- if (!empty($this->status)) $this->status = $this->status->fetch();
+ $sth = $this->db()->conn->query($sql,PDO::FETCH_ASSOC);
+ if (!empty($sth)) $this->status = $sth->fetch();
+
+ foreach ([
+ 'engine',
+ 'created',
+ ] as $k) {
+ if (empty($this->$k) and !empty($this->status[$k])) $this->$k = $this->status[$k];
+ }
}
+
+ foreach ([
+ 'count',
+ 'fields',
+ 'sql',
+ ] as $k) {
+ if (!self::p($k) or !empty($this->status[$k])) continue;
+ $this->status[$k] = $this->$k();
+ if (is_array($this->status[$k])) $this->status[$k] = count($this->status[$k]);
+ }
+
if (!empty($key)) return ( empty($this->status[$key]) ? '' : $this->status[$key] );
return $this->status;
}