Have been doing some comparisons between PEAR and PDO accessing Firebird "Employee" sample database and have found that PDO is not returning the first record, but is returning all subsequent records. Here are my snippets....
*** PEAR CODE **
include( "DB.php" );
$dbh = DB::connect( "ibase(firebird)://$user:$pw@localhost:3050/$dbf" );
if (PEAR::isError($dbh)) {
die($dbh->getMessage());
}
$sql = "SELECT *
FROM country";
$rs = $dbh->query($sql);
if (DB::iserror($rs)) {
die($rs->getMessage( ));
}
while ($rs->fetchInto($row)) {
print_r( $row );
}
$dbh->disconnect();
** PEAR RESULTS ***
Array
(
[0] => USA
[1] => Dollar
)
Array
(
[0] => England
[1] => Pound
)
Array
(
[0] => Canada
[1] => CdnDlr
)
...
*** PDO CODE **
try {
$dbh = new PDO("firebird:dbname=localhost:$dbf", $user, $pw);
$sql = "SELECT *
FROM country";
foreach ($dbh->query($sql) as $row) {
print_r($row);
}
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
$dbh = null;
** PDO RESULTS ***
Array
(
[COUNTRY] =>
[0] =>
[CURRENCY] =>
[1] =>
)
Array
(
[COUNTRY] => England
[0] => England
[CURRENCY] => Pound
[1] => Pound
)
Array
(
[COUNTRY] => Canada
[0] => Canada
[CURRENCY] => CdnDlr
[1] => CdnDlr
)
...
Notice that USA exists in the PEAR results only. PDO has created empty array elements.
What could be causing this?
Cheers,
SuperTwentyTwo