|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-31 10:39 UTC] brent dot halsey at huntington dot com
Description:
------------
I try to get the names of tables back from the results of db2_tables, but none of the fetch functions will get any data from it. I know it has data because of the var_dump on the results of the db2_tables command. I can't find any example of how to use this properly, but I can't get it to work at all.
Reproduce code:
---------------
// $conn has been established and is valid.
$myTable = db2_tables($conn, 'SHADOWDB');
while ($row=db2_fetch_array($myTable))
{
echo "$row[0]<br>";
echo "$row[1]<br>";
echo "$row[2]<br>";
echo "$row[3]<br>";
echo "$row[4]<br>";
var_dump($row);
}
var_dump($myTable);
Expected result:
----------------
for each table in the db 'SHADOWDB', I should get all of the data printed out to screen.
Actual result:
--------------
nothing prints from the while loop. The var_dump at the end prints this: "resource(17) of type (DB2 Statement) "
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
Thank you for taking the time to write to us, but this is not a bug. Hi Brent, The db2_tables functions does not have a parameter in which you can put the database to get all of the tables from. The parameters offer qualifier, schema, table name, and table type. I would imagine that for your system the schema would be the best (if on Linux). For example: <?php $conn = db2_connect('db', 'user', '****'); if ($conn) { $result = db2_tables($conn, NULL, "USER"); while ($row = db2_fetch_array($result)) { echo $row[2] . "\n"; } } ?> This script, on Linux, would print all the table names for the "USER" schema (which would be your username on Linux if you didn't specifically create a separate schema). I hope this helps. You can also view the documentation here: http://us2.php.net/manual/en/function.db2-tables.php