Hi Sam,

Currently the Zend_Db class doesn't pass PDO attributes through, but
this has been suggested and we may get to it later.  See
http://framework.zend.com/issues/browse/ZF-285

In the meantime, one workaround is to access the connection stored
within the Zend_Db_Adapter object, and then you can call PDO connection
methods like setAttribute().

$db = Zend_Db::factory(...);
$db->getConnection()->setAttribute(...);

In ZF 0.7 and earlier, getConnection() doesn't guarantee that the
connection is open.  You have to have executed at least one query first.
In ZF 0.8, getConnection() initiates the connection if it isn't already
connected.  If you want to apply the one-line change to ZF 0.7, here's
the diff:

http://framework.zend.com/fisheye/browse/Zend_Framework/trunk/library/Ze
nd/Db/Adapter/Abstract.php?r1=3284&r2=3287

Regards,
Bill Karwin

> -----Original Message-----
> From: Sam Davey [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 20, 2007 1:44 PM
> To: [email protected]
> Subject: [fw-general] Zend_Db - setting PDO attribute
> 
> 
> Hi,
> Although I have asked this in another post (see ...SQLSTATE[HY000]...
> post)
> I realised I had posted far too much information to get a response
from
> busy
> developers.
> 
> Short story:
> For some reason I need to set the following PDO attribute for it to
work
> with my server configuration
> 
> $db = new PDO('mysql:host=localhost;dbname='.DBNAME, DBUSER, DBPASS);
> $db->setAttribute (PDO::ATTR_EMULATE_PREPARES, true);
> 
> Can someone tell me how to set the attribute using the Zend_Db factory
or
> corresponding Zend_Db_Adapter class? I've had a look at the Manual and
API
> and I originally assumed that I simply passed it to the Factory class
via
> the config array but this did not work.  I tried:
> 
> $config[ATTR_EMULATE_PREPARES] = true;
> $config["ATTR_EMULATE_PREPARES"] = true;
> 
> But this did not work.
> 
> Any ideas?
> --
> View this message in context:
http://www.nabble.com/Zend_Db---setting-PDO-
> attribute-tf3263396s16154.html#a9070979
> Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to