× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Should this line be assignment:

} while ($column = db2_fetch_assoc($cols)) ;

or comparison:

} while ($column == db2_fetch_assoc($cols)) ;



----- Original Message ----- From: "Cyndi Bradberry" <CyndiB@xxxxxxxx>
To: <WEB400@xxxxxxxxxxxx>
Sent: Monday, August 24, 2009 2:56 PM
Subject: [WEB400] Help with PHP questions


Ok, I am finally getting a chance to work on my PHP book again. I am
using The IBM I Programmer's Guide to PHP, page 246 figure 8.12 as my
source code;

<?php
//Set the database name
$tableName = 'SYSTABLES' ;
$libName = 'QSYS2' ;

//Create the connection to the System i Relational Database
if (($dbh = db2_connect('BOISE','OPERIT','ITOPER')) === false) {
echo 'connection failed.<br>' ;
echo db2_conn_errormsg().'<br>' ;
die() ;
}

//Retrieve a result set with the column info for the
//file specified at the top of the script.
if (($cols = db2_columns( $dbh, null, $libName, $tableName, '%' )) ===
FALSE) {
echo 'colums retrieval failed. <BR>' ;
echo db2_stmt_errormsg(). '<BR>' ;
die() ;
}

//Fetch the first row and output the file name
// and library name from the result set.
$column = db2_fetch_assoc($cols) ;
echo 'FileTable: ' ;
echo $column["TABLE_SCHEM"]."/".$column["TABLE_NAME"]."<BR>" ;

//Loop thru all the result set rows and list all the column names.

do {
echo $column["COLUMN_NAME"]."<BR>" ;
} while ($column = db2_fetch_assoc($cols)) ;
?>

I get a triangle with an exclamation point next to the } while line at
the bottom of the code, which when I hover over, it shows this:

Multiple annotations found at this line:
- Line Breakpoint: db2Script1.php [line: 31 ]
- bool-assign : Assignment in condition

The script runs (now, not sure why) and I get this output:

FileTable: QSYS2/SYSTABLES
TABLE_NAME
TABLE_OWNER
TABLE_TYPE
COLUMN_COUNT
ROW_LENGTH
TABLE_TEXT
LONG_COMMENT
TABLE_SCHEMA
LAST_ALTERED_TIMESTAMP
SYSTEM_TABLE_NAME
SYSTEM_TABLE_SCHEMA
FILE_TYPE
BASE_TABLE_SCHEMA
BASE_TABLE_NAME
BASE_TABLE_MEMBER
SYSTEM_TABLE
SELECT_OMIT
IS_INSERTABLE_INTO
IASP_NUMBER
ENABLED
MAINTENANCE
REFRESH
REFRESH_TIME
MQT_DEFINITION
ISOLATION
PARTITION_TABLE
TABLE_DEFINER

Should I be able to change to any file/library (Table/Schema) on the
system and get a list of the columns in the table ? When I change the names in $tableName and $libName, I only get
FileTable: / as a response.

I know I have to be missing something simple here. Manual references
that will explain things are enjoyed.

Cyndi B.
Boise, ID --
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.