PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #5204

Informix driver does not support stored procedures returning values

Details

Submitted2005-08-25 04:41 UTC
Fromarachnid at notdot dot net
Assignedaharvey
StatusClosed
PackageDB
PHP Version5.0.5
OSWindows XP
Roadmaps(Not assigned)

Comments

[2005-08-25 04:41 UTC] arachnid at notdot dot net

Description:
------------
When executing a data-returning stored procedure on an Informix database (Informix's procedure call format is 'execute procedure proc_name(parameters)'), PEAR DB's Informix driver discards the results because the query does not start with SELECT, and instead returns DB_OK.

Test script:
---------------
<?php
require_once 'DB.php';
$dsn = array(
'phptype' => 'ifx',
'username' => 'dbuser',
'password' => 'dbpassword',
'database' => 'informixdb'
);

$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL
);

$db = DB::connect($dsn, $options);
print_r($db->getAll('execute procedure stored_proc(123)'));
?>

Expected result:
----------------
Array
(
[[Expr_1]] => 1000000
[[Expr_2]] => 1000000
)

Actual result:
--------------
1

[2005-08-25 22:09 UTC] arachnid at notdot dot net

Unified diff patch:
-----

--- /c/php/PEAR/DB/ifx.php Fri Aug 26 10:01:18 2005
+++ /c/Documents and Settings/nick/My Documents/ifx.php Fri Aug 26 09:58:03 2005
@@ -246,7 +246,7 @@
$ismanip = DB::isManip($query);
$this->last_query = $query;
$this->affected = null;
- if (preg_match('/(SELECT|EXECUTE)/i', $query)) { //TESTME: Use !DB::isManip()?
+ if (preg_match('/(SELECT)/i', $query)) { //TESTME: Use !DB::isManip()?
// the scroll is needed for fetching absolute row numbers
// in a select query result
$result = @ifx_query($query, $this->connection, IFX_SCROLL);
@@ -268,7 +268,7 @@
$this->affected = @ifx_affected_rows($result);
// Determine which queries should return data, and which
// should return an error code only.
- if (preg_match('/(SELECT|EXECUTE)/i', $query)) {
+ if (preg_match('/(SELECT)/i', $query)) {
return $result;
}
// XXX Testme: free results inside a transaction

-----

More effective would probably be to follow the 'testme' suggestion, and replace the regexps with calls to !DB::isManip(). As it stands, this code will treat anything _containing_ 'select' (and now 'execute') as a data returning query.