# Tables - Add missing infos
if (!empty($tables)) {
+
foreach ($this->tables() as $name=>$t) {
+ #foreach (array_merge(array_keys($this->tables()),[]) as $name) {
+ #foreach (array_merge(array_keys($this->tables()),array_keys($tables)) as $name) {
+
if (empty($tables[$name])) continue;
$this->table($name,$tables[$name]);
+
+ }
+
+ # Virtual - NB 04.07.16
+ foreach ($tables as $name => $t) {
+ if (empty($t['sql'])) continue;
+ $sql = $t['sql'];
+ unset($t['sql']);
+ #debug($name);
+ $t = $this->table($name,$t);
+ $t->sql = $sql;
+ $t->type = 'sql';
+ $this->tables[] = $t;
}
+
}
# Extras should disapear - NB 29.03.16
}
function table($name,$opt=array()) {
-# NB 29.03.16 if (empty($opt['db'])) $opt['db'] = $this;
if ($this->tables() and array_key_exists($name,$this->tables)) {
#if ($opt) bye($opt);
if ($opt) $this->tables[$name]->__construct($name,$opt);
return $this->tables[$name];
}
return new Table($name,$opt);
- bye("Unknow table `$name`");
}
public function localFile() {
return $DB_TYPES[$type][$key];
}
+# NB 04.07.16 public function all_tables() {
+# NB 04.07.16 $tables= $this->tables();
+# NB 04.07.16 return $tables;
+# NB 04.07.16 }
+
public function tables() {
- if (isset($this->tables)) return $this->tables;
- $this->tables = array();
- foreach ($this->conn->query($this->type('tables',true,$this->type),PDO::FETCH_ASSOC) as $row) {
- $name = current($row);
- $this->tables[$name] = $this->table($name,$row);
+ if (!isset($this->tables)) {
+ $this->tables = array();
+
+ foreach ($this->conn->query($this->type('tables',true,$this->type),PDO::FETCH_ASSOC) as $row) {
+ $name = current($row);
+ $this->tables[$name] = $this->table($name,$row);
+ }
+
}
return $this->tables;