php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 15 = ?
Subscribe to this entry?

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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:

<?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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 02:01:30 2024 UTC