PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #7632

oracle: unable to get numRows from prepared query

Details

Submitted2006-05-15 19:25 UTC
Fromces dot fci at gmail dot com
Assignedaharvey
StatusClosed
PackageDB
PHP Version5.1.2
OSRed Hat Enterprise Linux ES
Roadmaps(Not assigned)

Comments

[2006-05-15 19:25 UTC] ces dot fci at gmail dot com

Description:
------------
numRows method uses $this->last_query for numRows.. this is not desired in certain dynamic scenarios. the $result argument is a resource and can't be used. I don't expect to see a fix to this but naturally you can just re-prepare the query each time and call numRows() since then the query will be stored in $this->last_query

Test script:
---------------
$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL,
'seqname_format' => '%s',
);

$hostspec = "(DESCRIPTION = (SDU=32768)
(TDU=32768)
(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = " . OCI_DEFAULT_SERVER . ")(Port = " . OCI_DEFAULT_PORT . ")))
(CONNECT_DATA =(SID = " . OCI_DEFAULT_SID . ")))";
$db = 'prod';

$dns = 'oci8://' . OCI_DEFAULT_USER . ':' . OCI_DEFAULT_PASS . '@'.rawurlencode($hostspec).'/'.$db;
$db = DB::connect($dns, $options);
// ...
$db->setFetchMode(DB_FETCHMODE_ASSOC);

$sth1 = $db->prepare("SELECT * FROM table1");

$sth2 = $db->prepare("INSERT INTO table2 VALUES(50, 'string')");

$rs1 = $db->execute($sth1);
$rs1_rows = $rs1->numRows();
if (PEAR::isError($rs1_rows)) {
echo $rs1_rows->userinfo.'<br />'; // displays insert query, expecting select
die($rs1_rows->getMessage());
}

Expected result:
----------------
No error expected and select query should be used for the numRows method, not the insert query.