Home » Database » MDB2_Driver_oci8 » Bug #9780
Mdb2 Oracle Driver getMessage() returns an array
Details
| Submitted | 2007-01-09 07:24 UTC |
|---|---|
| From | pcdinh at gmail dot com |
| Assigned | quipo |
| Status | Closed |
| Package | MDB2_Driver_oci8 |
| PHP Version | 5.2.0 |
| OS | Windows Xp Sp2 |
| Roadmaps | (Not assigned) |
Comments
[2007-01-09 07:24 UTC] pcdinh at gmail dot com
Description:
------------
There is a bug in Oracle driver for MDB2 that affects the behaviour of the method getMessage().
I tried to execute a wrong SQL syntax statement and expected getMessage() will return a meaningful error notice.
However I have got as follows:
MDB2 Error: Array
I tried to var_dump() MDB2_Error and found:
object(MDB2_Error)#12 (8) {
["error_message_prefix"]=>
string(0) ""
["mode"]=>
int(1)
["level"]=>
int(1024)
["code"]=>
NULL
["message"]=>
string(17) "MDB2 Error: Array"
["userinfo"]=>
string(224) "_doQuery: [Error message: Could not execute statement]
[Last executed query: select PRIMARY_SHORT_COMPANY_NAME from wvb_company where company_perm_id #= 454]
[Native code: 911]
[Native message: ORA-00911: invalid character]
"
["backtrace"]=>
array(13) {
[0]=>
array(7) {
["file"]=>
string(31) "D:\wvbsrc\library\pear\MDB2.php"
["line"]=>
int(961)
["function"]=>
string(10) "PEAR_Error"
["class"]=>
string(10) "PEAR_Error"
["object"]=>
object(MDB2_Error)#12 (8) {
["error_message_prefix"]=>
string(0) ""
["mode"]=>
int(1)
["level"]=>
int(1024)
["code"]=>
NULL
["message"]=>
string(17) "MDB2 Error: Array"
["userinfo"]=>
string(224) "_doQuery: [Error message: Could not execute statement]
[Last executed query: select PRIMARY_SHORT_COMPANY_NAME from wvb_company where company_perm_id #= 454]
[Native code: 911]
[Native message: ORA-00911: invalid character]
Test script:
---------------
select PRIMARY_SHORT_COMPANY_NAME from wvb_company where company_perm_id #= 454
Any wrong Sql statement
Expected result:
----------------
MDB2 Error: ........... (some text here, not an array)
Actual result:
--------------
MDB2 Error: Array
[2007-01-09 08:38 UTC] pcdinh at gmail dot com
There is a mismatch between the constructor:
function MDB2_Error($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN,
$level = E_USER_NOTICE, $debuginfo = null)
{
$this->PEAR_Error('MDB2 Error: '.MDB2::errorMessage($code), $code,
$mode, $level, $debuginfo);
}
and PEAR::raiseError
The code to instantiate an object of MDB2_Error
$err =& PEAR::raiseError(NULL, $code, $mode, $options, $userinfo, 'MDB2_Error', false);
that will make a call to PEAR::raiseError that includes these logic:
if ($skipmsg) {
$a = &new $ec($code, $mode, $options, $userinfo);
return $a;
} else {
$a = &new $ec($message, $code, $mode, $options, $userinfo);
return $a;
}
because $skipmsg is set to be true so $a = &new $ec($code, $mode, $options, $userinfo); will be called
But in fact $code is null and MDB2::errorMessage($code) will return an array.
In MDb2::raiseError() the initial parameter $userinfo in fact can be acted as $message but it is ignored
[2007-01-09 08:59 UTC] pcdinh at gmail dot com
File oci8.php, line 637
$result = @OCIParse($connection, $query);
if (!$result) {
$err = $this->raiseError(null, null, null,
'Could not create statement', __FUNCTION__);
return $err;
}
Code has been assigned as null.