ZF-3011: DB2 on i5 fails because of table and column names quoting
Description
The following script was used:
<?php
require_once 'Zend/Db/Adapter/Db2.php';
$db = new Zend_Db_Adapter_Db2(
array(
'username'=>"LOUISA",
'password'=>"*******",
'dbname'=>"xxxxxx")
);
$db->insert("animals",Array("a"=>"Serg ","b"=>"Just a","c"=>"12345"));
$v=$db->fetchRow("select * from animals where a='Serg '");
var_dump($v);
It fails with the following result:
[01-Apr-2008 07:37:45] PHP Warning: db2_prepare(): Statement Prepare Failed in /usr/local/Zend/ZendFramework/library/Zend/Db/Statement/Db2.php on line 64
[01-Apr-2008 07:37:45] PHP Fatal error: Uncaught exception 'Zend_Db_Statement_Db2_Exception' with message '"animals" in LOUISA type *FILE not found. SQLCODE=-204' in /usr/local/Zend/ZendFramework/library/Zend/Db/Statement/Db2.php:72
Stack trace:
#0 /usr/local/Zend/ZendFramework/library/Zend/Db/Statement.php(109): Zend_Db_Statement_Db2->_prepare('INSERT INTO "an...')
#1 /usr/local/Zend/ZendFramework/library/Zend/Db/Adapter/Db2.php(199): Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Db2), 'INSERT INTO "an...')
#2 /usr/local/Zend/ZendFramework/library/Zend/Db/Adapter/Abstract.php(395): Zend_Db_Adapter_Db2->prepare('INSERT INTO "an...')
#3 /usr/local/Zend/ZendFramework/library/Zend/Db/Adapter/Abstract.php(474): Zend_Db_Adapter_Abstract->query('INSERT INTO "an...', Array)
#4 /usr/local/Zend/ZendFramework/t1.php(10): Zend_Db_Adapter_Abstract->insert('animals', Array)
#5 {main}
thrown in /usr/local/Zend/ZendFramework/library/Zend/Db/Statement/Db2.php on line 72
var_dump() within Db2.php just before db2_prepare call gives the following result:
string(54) "INSERT INTO "animals" ("a", "b", "c") VALUES (?, ?, ?)"
The following script works OK:
$conn = db2_connect("xxxxxx", "LOUISA", "*******");
if ($conn) {
echo "Connection succeeded.
";
}
else {
echo "Connection failed.
";
exit;
}
$r=db2_prepare($conn,'insert into animals (a,b,c) values (?,?,?)');
$v=db2_execute($r,Array('a'=>'A1','b'=>'B1','c'=>'C1'));
Comments
Posted by Darby Felton (darby) on 2008-04-08T13:17:46.000+0000
Alex, how did you come to report this issue? Are you running DB2 on i5 somewhere?
Posted by Alexander Veremyev (alexander) on 2008-04-09T18:23:35.000+0000
Sergey Korolyov "serg at zend.com" (original reporter of the problem) has an access to DB2 on i5. We could ask him to make tests we need. Probably he can also provide an access to DB2 on i5 for us.
PS He also lives in SPb, but doesn't have a habit to work at nights :) So if you write him now, his respond will come with some delay
Posted by Wil Sinclair (wil) on 2008-04-18T13:20:28.000+0000
Please evaluate and categorize as necessary.
Posted by Alessandro Camilli (alex_cam) on 2008-06-26T02:42:47.000+0000
I have the same problem with i5 and os v5r3.
You can contact me at a.camilli@scami.it if you want more information of the problem
Posted by Ralph Schindler (ralph) on 2009-01-10T11:41:33.000+0000
This was fixed in ZF 1.7.2 with the new i5 enabled adapter.