execute and executeEmulatedQuery question
| From: | yavor shahpasov | Date: | Wed, 25 Jul 2001 22:34:49 +0000 |
| Subject: | execute and executeEmulatedQuery question | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-1058@lists.php.net to get a copy of this message | ||
I'm trying to change the oci8 extension to work with ref cursors. Now it
seems other backends (MySQL) use the default execute/executeEmulatedQuery
methods of DB::Common. The point is that execute in DB::common returns a
DB::result object while the DB::oci8 execute method returns a native oci8
result (or and executed statement if you prefer) . Is this the correct
behavior or should it return a DB::result object. I changed it to return a
DB::result object and it seems to work. I run the tests for oci8, I'm not
sure if the output is correct, I have included it below.
I have included also the patch, wasn't brave enough to commit it and I
probably don't have the karma any how. Can some one please test it.
ex:
include("DB.php");
$db = DB::connect("oci8://user:pass@db_name");
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
$sql = "BEGIN itena2.broker.GetPLACED( ? , @ ); end;";
$data = $db->getAll($sql, array("CHR", null), DB_FETCHMODE_ASSOC);
print_r($data);
where ? is the parameter passed to the stored procedure and @ is the
returning ref cursor. Only one ref cursor is supported. When executed the
ref cursor replaces the default statement so any other out params will be
impossible to retrieve.
Note a new constant must be declared in DB.php for this to work
DB_PARAM_CURSOR
Yavor Shahpasov
The difference between a good man and a bad one is the choice of cause -
William James
--TEST-- DB_oci8::connect test --SKIPIF-- --FILE-- $dbh is an object $dbh is connected --EXPECT-- $dbh is an object $dbh is connected --TEST-- DB_oci8 fetch test --SKIPIF-- --FILE-- testing fetchrow: row 1: 42, bing, This is a test, 1999-11-21 row 2: 1, one, One, 2001-02-16 row 3: 2, two, Two, 2001-02-15 row 4: 3, three, Three, 2001-02-14 row 5: NULL testing fetchmodes: fetchrow default default 0 1 2 3 testing fetchmodes: fetchinto default default 0 1 2 3 testing fetchmodes: fetchrow ordered default 0 1 2 3 testing fetchmodes: fetchrow assoc default A B C D testing fetchmodes: fetchrow ordered default with assoc specified A B C D testing fetchmodes: fetchrow assoc default with ordered specified 0 1 2 3 testing fetchmodes: fetchinto ordered default 0 1 2 3 testing fetchmodes: fetchinto assoc default A B C D testing fetchmodes: fetchinto ordered default with assoc specified A B C D testing fetchmodes: fetchinto assoc default with ordered specified 0 1 2 3 --EXPECT-- testing fetchrow: row 1: 42, bing, This is a test, 1999-11-21 row 2: 1, one, One, 2001-02-16 row 3: 2, two, Two, 2001-02-15 row 4: 3, three, Three, 2001-02-14 row 5: NULL testing fetchmodes: fetchrow default default 0 1 2 3 testing fetchmodes: fetchinto default default 0 1 2 3 testing fetchmodes: fetchrow ordered default 0 1 2 3 testing fetchmodes: fetchrow assoc default A B C D testing fetchmodes: fetchrow ordered default with assoc specified A B C D testing fetchmodes: fetchrow assoc default with ordered specified 0 1 2 3 testing fetchmodes: fetchinto ordered default 0 1 2 3 testing fetchmodes: fetchinto assoc default A B C D testing fetchmodes: fetchinto ordered default with assoc specified A B C D testing fetchmodes: fetchinto assoc default with ordered specified 0 1 2 3 --TEST-- DB_oci8::simpleQuery test --SKIPIF-- --FILE-- resource --EXPECT-- resource --TEST-- DB_oci8::numCols test --SKIPIF-- --FILE-- 1 2 3 4 --EXPECT-- 1 2 3 4 --TEST-- DB_oci8::prepare/execute test --SKIPIF-- --FILE-- sth1,sth2,sth3 created results: 72 - - - 72 - bing - - 72 - gazonk - opaque placeholder test - --EXPECT-- sth1,sth2,sth3 created sth1 executed sth2 executed sth3 executed results: 72 - - - 72 - bing - - 72 - gazonk - opaque placeholder test - --TEST-- DB_oci8::errorNative test --SKIPIF-- skip --FILE-- --EXPECT-- --TEST-- DB_oci8::affectedRows test --SKIPIF-- --FILE-- 1 after insert 0 after select 2 after delete 3 after delete all --EXPECT-- 1 after insert 0 after select 2 after delete 3 after delete all --TEST-- DB_oci8::numRows test --SKIPIF-- --FILE-- 1 2 3 4 5 6 2 0 DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable --EXPECT-- 1 2 3 4 5 6 2 0 DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable --TEST-- DB_oci8 error mapping --SKIPIF-- --FILE-- Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_ALREADY_EXISTS DB Error: already exists Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_CONSTRAINT DB Error: constraint violation DB Error: constraint violation Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER DB Error: invalid number Trying to provoke DB_ERROR_NOSUCHFIELD DB Error: no such field Trying to provoke DB_ERROR_SYNTAX DB Error: syntax error --EXPECT-- Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_ALREADY_EXISTS DB Error: already exists Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_CONSTRAINT DB Error: constraint violation DB Error: constraint violation Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER DB Error: invalid number Trying to provoke DB_ERROR_NOSUCHFIELD DB Error: no such field Trying to provoke DB_ERROR_SYNTAX DB Error: syntax error --TEST-- DB_oci8 sequences --SKIPIF-- --FILE-- DB Error: no such table a=1 b=2 b-a=1 sequences.inc error_handler c=1 sequences.inc error_handler d=1 --EXPECT-- DB Error: no such table a=1 b=2 b-a=1 c=1 d=1
--TEST-- DB_oci8::connect test --SKIPIF-- --FILE-- $dbh is an object $dbh is connected --EXPECT-- $dbh is an object $dbh is connected --TEST-- DB_oci8 fetch test --SKIPIF-- --FILE-- testing fetchrow: row 1: 42, bing, This is a test, 1999-11-21 row 2: 1, one, One, 2001-02-16 row 3: 2, two, Two, 2001-02-15 row 4: 3, three, Three, 2001-02-14 row 5: NULL testing fetchmodes: fetchrow default default 0 1 2 3 testing fetchmodes: fetchinto default default 0 1 2 3 testing fetchmodes: fetchrow ordered default 0 1 2 3 testing fetchmodes: fetchrow assoc default A B C D testing fetchmodes: fetchrow ordered default with assoc specified A B C D testing fetchmodes: fetchrow assoc default with ordered specified 0 1 2 3 testing fetchmodes: fetchinto ordered default 0 1 2 3 testing fetchmodes: fetchinto assoc default A B C D testing fetchmodes: fetchinto ordered default with assoc specified A B C D testing fetchmodes: fetchinto assoc default with ordered specified 0 1 2 3 --EXPECT-- testing fetchrow: row 1: 42, bing, This is a test, 1999-11-21 row 2: 1, one, One, 2001-02-16 row 3: 2, two, Two, 2001-02-15 row 4: 3, three, Three, 2001-02-14 row 5: NULL testing fetchmodes: fetchrow default default 0 1 2 3 testing fetchmodes: fetchinto default default 0 1 2 3 testing fetchmodes: fetchrow ordered default 0 1 2 3 testing fetchmodes: fetchrow assoc default A B C D testing fetchmodes: fetchrow ordered default with assoc specified A B C D testing fetchmodes: fetchrow assoc default with ordered specified 0 1 2 3 testing fetchmodes: fetchinto ordered default 0 1 2 3 testing fetchmodes: fetchinto assoc default A B C D testing fetchmodes: fetchinto ordered default with assoc specified A B C D testing fetchmodes: fetchinto assoc default with ordered specified 0 1 2 3 --TEST-- DB_oci8::simpleQuery test --SKIPIF-- --FILE-- resource --EXPECT-- resource --TEST-- DB_oci8::numCols test --SKIPIF-- --FILE-- 1 2 3 4 --EXPECT-- 1 2 3 4 --TEST-- DB_oci8::prepare/execute test --SKIPIF-- --FILE-- sth1,sth2,sth3 created results: 72 - - - 72 - bing - - 72 - gazonk - opaque placeholder test - --EXPECT-- sth1,sth2,sth3 created sth1 executed sth2 executed sth3 executed results: 72 - - - 72 - bing - - 72 - gazonk - opaque placeholder test - --TEST-- DB_oci8::errorNative test --SKIPIF-- skip --FILE-- --EXPECT-- --TEST-- DB_oci8::affectedRows test --SKIPIF-- --FILE-- 1 after insert 0 after select 2 after delete 3 after delete all --EXPECT-- 1 after insert 0 after select 2 after delete 3 after delete all --TEST-- DB_oci8::numRows test --SKIPIF-- --FILE-- 1 2 3 4 5 6 2 0 DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable --EXPECT-- 1 2 3 4 5 6 2 0 DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable DB Error: DB backend not capable --TEST-- DB_oci8 error mapping --SKIPIF-- --FILE-- Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_ALREADY_EXISTS DB Error: already exists Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_CONSTRAINT DB Error: constraint violation DB Error: constraint violation Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER DB Error: invalid number Trying to provoke DB_ERROR_NOSUCHFIELD DB Error: no such field Trying to provoke DB_ERROR_SYNTAX DB Error: syntax error --EXPECT-- Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_ALREADY_EXISTS DB Error: already exists Trying to provoke DB_ERROR_NOSUCHTABLE DB Error: no such table Trying to provoke DB_ERROR_CONSTRAINT DB Error: constraint violation DB Error: constraint violation Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero Trying to provoke DB_ERROR_INVALID_NUMBER DB Error: invalid number Trying to provoke DB_ERROR_NOSUCHFIELD DB Error: no such field Trying to provoke DB_ERROR_SYNTAX DB Error: syntax error --TEST-- DB_oci8 sequences --SKIPIF-- --FILE-- DB Error: no such table a=1 b=2 b-a=1 sequences.inc error_handler c=1 sequences.inc error_handler d=1 --EXPECT-- DB Error: no such table a=1 b=2 b-a=1 c=1 d=1