note 11870 modified in function.odbc-tables by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 18:59:19 +0000 |
| Subject: | note 11870 modified in function.odbc-tables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142535@lists.php.net to get a copy of this message | ||
Here's how to get a list of all the tables in your database.. with an actual example of how its
done and how to get the results.. and you don't need to put in schema and all that other crap
<?php
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
if (odbc_result($tablelist, 4) == "TABLE")
echo odbc_result($tablelist, 3) ."<br>";
}
?>
to understand what the above is doing,
use odbc_result_all($tablelist); this will show you EVERYTHING returned by odbc_tables() then you
can look through it and see better how odbc_tables() works and what exactly it returns in the string
to get a better idea on how to deal with it.
it would have saved me alot of time if i would have just taken a look at the full string returned by
odbc_tables(), so i suggest you take the minute or two and look... here is an example of how to do
it..which would have been helpful for me ;x.
<?php
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
echo odbc_result_all($tablelist);
}
?>
hopefully this will help some people.. i have alot more to add about this but no time :(
so again hope this helps.
Liquidice
--was--
Here's how to get a list of all the tables in your database.. with an actual example of how its
done and how to get the results.. and you don't need to put in schema and all that other crap
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
if (odbc_result($tablelist, 4) == "TABLE")
echo "" . odbc_result($tablelist, 3) ."<br>";
}
to understand what the above is doing,
use odbc_result_all($tablelist); this will show you EVERYTHING returned by odbc_tables() then you
can look through it and see better how odbc_tables() works and what exactly it returns in the string
to get a better idea on how to deal with it.
it would have saved me alot of time if i would have just taken a look at the full string returned by
odbc_tables(), so i suggest you take the minute or two and look... here is an example of how to do
it..which would have been helpful for me ;x.
<?php
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
echo odbc_result_all($tablelist);
}
?>
hopefully this will help some people.. i have alot more to add about this but no time :(
so again hope this helps.
Liquidice
http://php.net/manual/en/function.odbc-tables.php