|
Posted by -Lost on 07/03/06 07:25
function list_tables($db_name)
{
$query = 'SHOW TABLES FROM ' . $db_name;
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
return $tables;
}
Firstly, you do not need to initialize a variable as an array (it is good coding practice
however). Secondly, instead of incurring the overhead of calling the array_push method,
you can simply use the $array[] = 'element'; technique.
Not sure why J.O. Aho thought that the first index would be empty, but oh well.
Also, mysql_list_tables still exists, but is deprecated.
-Lost
Navigation:
[Reply to this message]
|