I didn't get a response to my last post which isn't a suprise since the
subject of the post is hardly something which inspires interest... but in an
effort to achieve the centralised store of a solution mentioned in the first
post, here is how I solved the issue.

Lukas Foldyna helpfully suggested the following: 
$db->getConnection()->setAttribute (PDO::ATTR_EMULATE_PREPARES, true); 

I tried this but I received the error message that getConnection was not a
valid method.

I created another post to see if anyone knew how to set the PDO attribute in
the Zend Framework and Bill Karwin provided a very detailed answer about
current issue/thoughts and a possible work around:
http://www.nabble.com/Zend_Db---setting-PDO-attribute-tf3263396s16154.html

But he confirmed that getConnection is indeed a valid method for the
Zend_Db_Adapter object returned by the Zend_Db factory.  Therefore Lukas
solution should have worked.

The problem I had was that Zend_Db_Adapter object creates a lazy connection
(i.e. it only actually creates the PDO connection when needed).  Apparently
the connection is automatically created in ZF 0.8 but I'm running ZF 0.7
therefore I had to add the following line to the
Zend/Db/Adapter/Abstract.php file
$this->_connect();

Obviously I shouldn't edit any library files but I did it as a quick fix
since 0.8 will be released soon.

Once I had done this I could include the following code without problem:
$db->getConnection()->setAttribute (PDO::ATTR_EMULATE_PREPARES, true); 

The DB interaction is fixed so I'm sorted.  I hope this information helps
anyone else who is having problems with PDO.

I'd be interested to find out why I need to set this attribute for PDO on
this server? and given that the information at this resource suggests this
is an optimal setting should it always be set?
http://netevil.org/node.php?nid=795&SC=1
-- 
View this message in context: 
http://www.nabble.com/PDOException-with-message-SQLSTATE-HY000-%3A-General-error%3A-2036-tf3239563s16154.html#a9072589
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to