}
- function get($tbl)
+ function get($tbl, $opts = array())
{
if (preg_match('/__keys$/', $k)) {
continue;
}
+ $do = DB_DataObject::factory($k);
+ if (!is_a($do,'DB_DataObject')) {
+ continue;
+ }
$ret[] = array(
'name' => $k,
'desc' => isset($desc[$k]) ? $desc[$k] : ''
// echo '<PRE>';print_R($desc);
$ret = array();
foreach($cols as $c => $ty) {
- $ret[] = $desc[$c];
- if (!isset($links[$c])) {
+
+ if (!isset($links[$c])) {
+ $ret[] = $desc[$c];
continue;
}
+ // we need to add dependant information to column details so
+ // that combo box can determine how to use it..
+
+
+
// colname_{remotename}_{col}
$kv = explode(':', $links[$c]);
- $ar = $this->createRet($dos[$c], $c . '_' . $kv[1] . '_');
+ //$ar = $this->createRet($dos[$c], $c . '_' . $kv[1] . '_');
+ $ar = $this->createRet($dos[$c], $c . '_' , $kv[1]);
+ $desc[$c]['maps_to'] = $kv[1];
+ $desc[$c]['deps'] = array_values($ar);
+
+ $ret[] = $desc[$c];
foreach($ar as $cn => $r) {
$ret[] = $r;
}
}
- // echo '<PRE>';print_R($ret);
+ // echo '<PRE>';print_R($ret);
$this->jdata($ret);
}
- function createRet($do, $pref='')
+ function createRet($do, $pref='', $skip = '')
{
- static $cache = array();
+ static $desc = array();
static $types= array();
$tn = $do->tableName();
-
+
+
+
+
+ // get a description if available..
if (!isset($desc[$tn])) {
+
+
+
+
+
+
$desc[$tn] = array();
$dd = clone($do);
c.table_schema = 'public' and c.table_name = '{$tn}'
");
while($dd->fetch()) {
- $cache[$tn][$dd->name] = $dd->desc;
+ $desc[$tn][$dd->name] = $dd->desc;
}
- $defs = $dd->databaseConnection()->tableInfo($quotedTable);
-
+ $defs = $dd->getDatabaseConnection()->tableInfo($tn);
+ $types[$tn] = array();
+ foreach($defs as $c) {
+ $types[$tn][$c['name']] = $c['type'];
+ }
+ //echo '<PRE>';print_r($defs);
}
$ret = array();
foreach($do->table() as $k=>$ty) {
+ if ($k == $skip) {
+ continue;
+ }
$ret[$k] = array(
'table' => $tn,
'column' => $pref . $k,
'columnshort' => $k,
- 'ctype' => $ty,
+ 'ctype' => $types[$tn][$k], // should always work!
'desc' => isset($cache[$tn][$k]) ? $cache[$tn][$k] : '',
);
}