Re: fetchRow problem with odbc...
| From: | Sergio Galassi | Date: | Fri, 19 Mar 2004 08:22:05 +0000 |
| Subject: | Re: fetchRow problem with odbc... | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11390@lists.php.net to get a copy of this message | ||
Guillaume Papin wrote:
Hello, excuse my very bad english i am french. For an application we used DB package from Pear and we want to connect the application with a DB2 database, the connection was ok, we can insert data intot table, when we execute a select query a resultset is return but when we use the fetchRow fonction in a while we always retrieve the first row ? If somebody has an ide ?Maybe a bit of code? It's much easier to help if you show the piece of code you think isn't working... I'm using PEAR:DB (release 1.6) with DB2 and I'm not experiencing any problem... this is how I do:
$sql = 'SELECT whatever FROM wherever';
$recordSet = $db->query($sql);
while ($row = $recordSet->fetchRow(DB_FETCHMODE_ASSOC)) {
... operations with recordset (an associative array with field names as keys)...
}
$row['whatever'] contains the value of 'whatever' field in your table...
the first step in while cycle $row contains first record in $recordSet.
the next step in while cycle $row array will contain next record in $recordSet.
So on until $row is empty i.e. $recordSet is fetched up.
Best regards,
Sergio.