BBabb
4 Oct 2007, 12:23 PM
I am using the example for the documents for Ext Dependency Builder. But of cource i'm complicating it now so instead of doing a directory browse i want it to read MySQL table structures.
Here is the dependencies.php i wrote (which the array seems correct)
$tables=mysql_query("show tables") or die(mysql_error());
$tmp="";
$nodes = array();
while($t=mysql_fetch_assoc($tables)) {
foreach ($t as $db => $table) {
if(empty($tmp) || $tmp != $table) {
$node = $table;
$nodes[] = array('text'=>$node, id=>$node, qtip=>"Table:".$node, iconCls=>'folder', allowDrag=>false);
}
$cells=mysql_query("SHOW COLUMNS FROM ".$table) or die(mysql_error());
while($c=mysql_fetch_assoc($cells)) {
$nodes[] = array('text'=>$c['Field'], id=>$node.'.'.$c['Field'], leaf=>true, qtip=>"Type: ".$c['Type'], qtipTitle=>$c['Field'], cls=>'file', allowDrag=>true);
}
$tmp = $table;
}
}
echo json_encode($nodes);
I haven't changed anything else. Can you give me some reason why it doesn't work?
Here is the dependencies.php i wrote (which the array seems correct)
$tables=mysql_query("show tables") or die(mysql_error());
$tmp="";
$nodes = array();
while($t=mysql_fetch_assoc($tables)) {
foreach ($t as $db => $table) {
if(empty($tmp) || $tmp != $table) {
$node = $table;
$nodes[] = array('text'=>$node, id=>$node, qtip=>"Table:".$node, iconCls=>'folder', allowDrag=>false);
}
$cells=mysql_query("SHOW COLUMNS FROM ".$table) or die(mysql_error());
while($c=mysql_fetch_assoc($cells)) {
$nodes[] = array('text'=>$c['Field'], id=>$node.'.'.$c['Field'], leaf=>true, qtip=>"Type: ".$c['Type'], qtipTitle=>$c['Field'], cls=>'file', allowDrag=>true);
}
$tmp = $table;
}
}
echo json_encode($nodes);
I haven't changed anything else. Can you give me some reason why it doesn't work?