foreach ($this->conn->query($sql,PDO::FETCH_ASSOC) as $row) {
#debug($row);
$name = current($row);
- $this->table($name,$row+['status'=>$row]); # add to this->tables too !
+ $t = $this->table($name,$row+['status'=>$row]); # add to this->tables too !
}
}
]);
} elseif ($action == 'db.tables') {
+
+ # Options
# Filters
$type = $this->p('type','');
$name = $this->p('name','');
$engine = $this->p('engine','');
#var_dump ($this->tables());
+#foreach($this->tables as $t) debug($t->name.'='.$t->type);
+#bye($this->tables);
foreach ($this->tables() as $t) {
- #debug($t->name);
+ #debug($t->name.'='.$t->type);
+
if (!empty($name) and !$this->str_match($t->name,$name)) continue;
if (!empty($type) and !$this->str_match($t->type,$type)) continue;
if (!empty($count) and !$this->str_match($t->count,$count)) continue;
if (!empty($engine) and !$this->str_match($t->engine,$engine)) continue;
- $rows[] = $t->status();
+ $row = $t->status();
+ if ($this->p('count')) $row['count'] = $t->status('count');
+ #if ($this->p('fields')) $row['fields'] = $t->status('fields');
+ if ($this->p('fields')) $row['fields'] = join(',',array_keys($t->fields()));
+
+ $rows[] = $row;
}
- #bye($rows);
$rows = self::array_fill_assoc($rows);
usort($rows,function($a,$b) { return strcmp($a['name'],$b['name']); });
$return = $this->out($rows);
'name',
'type',
] as $k) {
- if (!empty($this->$k) and empty($this->status[$k])) $this->status[$k] = $this->$k;
+# NB 28.10.16 if (!empty($this->$k) and empty($this->status[$k])) $this->status[$k] = $this->$k;
+ if (!empty($this->$k)) $this->status[$k] = $this->$k;
}
# Add from status array
}
}
+ #$key = 'count';
+ # Params
foreach ([
'count',
'fields',
'sql',
] as $k) {
- if (!self::p($k) or !empty($this->status[$k])) continue;
+ if (!empty($this->status[$k])) continue;
+
+ if (empty($key)) {
+ if (!self::p($k)) continue;
+ } else {
+ if ($k!=$key) continue;
+ }
# No count for view
- if ($k == 'count' and $this->type != 'table') continue;
+ #if ($k == 'count' and $this->type != 'table') 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] );
+#debug($this->name.'='.$this->type);
return $this->status;
}