|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #57503 db2_tables result set
Submitted: 2007-01-31 10:39 UTC Modified: 2007-02-02 12:47 UTC
From: brent dot halsey at huntington dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.1.4 OS: SUSE
Private report: No CVE-ID: None
 [2007-01-31 10:39 UTC] brent dot halsey at huntington dot com
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>";



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) "


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-02 12:47 UTC] kfbombar at us dot ibm dot com
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:


$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:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 22 17:01:24 2021 UTC