I'm having some trouble with Pear DB, if anyone can help me out, I'd appreciate it. It concerns fetching a specific row inside a result.

I'm using the pear version included in PHP 4.04

<?php
require_once 'DB.php';
$dsn = "oci8://user:pass@host";
$db = DB::connect($dsn);
if (DB::isError($db)) { die ($db->getMessage()); }
$sql = "select from dca_catmaster";
$result = $db->query($sql);
if (DB::isError($result)) { die ($result->getMessage()); }
echo "Selected. <br>";
// This prints out "Object" on the screen.
echo $result->numRows();
$rowNum = 0;
// if I do this, I'm fine. I get my data, ugly as it is.
/
while ($row = $result->fetchRow()) {
foreach($row as $column){ echo "$column<br>"; }
}
/
// This, however, always gives me the following:
/

1
1024
-9
DB Error: DB backend not capable

select from dca_catmaster
/
foreach (range(0, 10) as $rownum) {

if (!$row = $result->fetchRow($fetchmode, $rownum)) { break; }

foreach($row as $column){ echo "$column<br>"; }
}
$db->disconnect();
?>

    a year later

    I'm getting the same error when attempting to query an oracle database using PEAR.

    I'm using PHP4 and IIS on Windows 2000.

      a month later

      The 'optimize' option can cause this problem. It must be set to 'portability' for the numRows() function to work. The default value of optimize is 'performance'.

      $dsn = "oci8://user:pass@host";
      $options = array(
      'persistent' => false,
      'optimize' => 'portability');

      $db = DB::connect( $dsn, $options );

        Write a Reply...