Re: [fw-general] Zend_Db specify character set

2008-10-01 Thread Rob Riggen
Thank you for the responses!

Rob

On Wed, Oct 1, 2008 at 2:29 AM, Stefan Gehrig [EMAIL PROTECTED] wrote:

  Hi Rob,



 there is another possibility if you're using the Zend_DB-PDO-Adapters:

 $db=Zend_Db::factory('Pdo_Mysql', array(

   'host'   = 'localhost',

   'username'   = 'user',

   'password'   = 'pa$$w0rd',

   'dbname' = 'database',

   'driver_options' = array(

 PDO::MYSQL_ATTR_INIT_COMMAND = 'SET NAMES utf8'

   )

 ));



 This ensures that the SET-NAMES-Command is issued with every reconnect of

 the underlying adapter.



 Best regards



 Stefan



 *Von:* Bradley Holt [mailto:[EMAIL PROTECTED]
 *Gesendet:* Dienstag, 30. September 2008 23:04
 *An:* Rob Riggen
 *Cc:* fw-general@lists.zend.com
 *Betreff:* Re: [fw-general] Zend_Db specify character set



 Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.

 On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen [EMAIL PROTECTED] wrote:

 Is there a way to force the character set on mysql db connections to UTF-8?

 Thanks,

 Rob

 *Robert Riggen* - Zend Certified Engineer
 *Big Yellow Technologies, LLC*

 Essex Junction, VT 05452
 802.578.6719
 [EMAIL PROTECTED]




 --
 Bradley Holt
 [EMAIL PROTECTED]



*Robert Riggen* - Zend Certified Engineer
*Big Yellow Technologies, LLC*

Essex Junction, VT 05452
802.578.6719
[EMAIL PROTECTED]


[fw-general] Zend_Db specify character set

2008-09-30 Thread Rob Riggen
Is there a way to force the character set on mysql db connections to UTF-8?

Thanks,

Rob

*Robert Riggen* - Zend Certified Engineer
*Big Yellow Technologies, LLC*

Essex Junction, VT 05452
802.578.6719
[EMAIL PROTECTED]


Re: [fw-general] Zend_Db specify character set

2008-09-30 Thread Bradley Holt
Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.

On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen [EMAIL PROTECTED] wrote:

 Is there a way to force the character set on mysql db connections to UTF-8?

 Thanks,

 Rob

 *Robert Riggen* - Zend Certified Engineer
 *Big Yellow Technologies, LLC*

 Essex Junction, VT 05452
 802.578.6719
 [EMAIL PROTECTED]




-- 
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] Zend_Db specify character set

2008-09-30 Thread Rob Riggen
Surely you don't do that on every call?

I'm using Zend_Db_Table so I'm not necessarily writing queries - where
can/should this be done?

Thanks!

Rob

On Tue, Sep 30, 2008 at 5:04 PM, Bradley Holt [EMAIL PROTECTED]wrote:

 Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.


 On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen [EMAIL PROTECTED] wrote:

 Is there a way to force the character set on mysql db connections to
 UTF-8?

 Thanks,

 Rob

 *Robert Riggen* - Zend Certified Engineer
 *Big Yellow Technologies, LLC*

 Essex Junction, VT 05452
 802.578.6719
 [EMAIL PROTECTED]




 --
 Bradley Holt
 [EMAIL PROTECTED]




Re: [fw-general] Zend_Db specify character set

2008-09-30 Thread Bradley Holt
Sorry, should have explained it a little more :-)

I just run that query once before the first real query, something like
this:

$dbAdapter-query('SET NAMES UTF8');

After running that once, you should be good for the rest of the connection.
In web applications where pretty every controller/action will need a
database connection I just do it right after I initialize the DB adapter:

$dbAdapter = Zend_Db::factory($this-_config-database));
$dbAdapter-query('SET NAMES UTF8');
Zend_Registry::getInstance()-dbAdapter = $dbAdapter;

Of course, this would open up an unnecessary database connection for
controllers/actions that don't need database connections. I don't have a
good answer for you on that - but basically you'd have to only run that
query when you know you'll need a database connection.

If anyone has a better way of doing this, I'd love to hear about it!

Thanks,
Bradley

On Tue, Sep 30, 2008 at 5:07 PM, Rob Riggen [EMAIL PROTECTED] wrote:

 Surely you don't do that on every call?

 I'm using Zend_Db_Table so I'm not necessarily writing queries - where
 can/should this be done?

 Thanks!

 Rob


 On Tue, Sep 30, 2008 at 5:04 PM, Bradley Holt [EMAIL PROTECTED]wrote:

 Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.


 On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen [EMAIL PROTECTED]wrote:

 Is there a way to force the character set on mysql db connections to
 UTF-8?

 Thanks,

 Rob

 *Robert Riggen* - Zend Certified Engineer
 *Big Yellow Technologies, LLC*

 Essex Junction, VT 05452
 802.578.6719
 [EMAIL PROTECTED]




 --
 Bradley Holt
 [EMAIL PROTECTED]





-- 
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] Zend_Db specify character set

2008-09-30 Thread Ralph Schindler
Have a look at 
http://framework.zend.com/issues/browse/ZF-1541

This is on the radar to get into ZF soon.  Effectively, this type of feature
would allow us (potentially) to make the call to ³Set names utf8² inside the
lazy-loaded getConnection() call in the adapter.

This way, its not enforced per-request in the bootstrap, but only on
requests that actually use the dbConnection.

-ralph


On 9/30/08 4:14 PM, Bradley Holt [EMAIL PROTECTED] wrote:

 Sorry, should have explained it a little more :-)
 
 I just run that query once before the first real query, something like this:
 
 $dbAdapter-query('SET NAMES UTF8');
 
 After running that once, you should be good for the rest of the connection. In
 web applications where pretty every controller/action will need a database
 connection I just do it right after I initialize the DB adapter:
 
 $dbAdapter = Zend_Db::factory($this-_config-database));
 $dbAdapter-query('SET NAMES UTF8');
 Zend_Registry::getInstance()-dbAdapter = $dbAdapter;
 
 Of course, this would open up an unnecessary database connection for
 controllers/actions that don't need database connections. I don't have a good
 answer for you on that - but basically you'd have to only run that query when
 you know you'll need a database connection.
 
 If anyone has a better way of doing this, I'd love to hear about it!
 
 Thanks,
 Bradley
 
 On Tue, Sep 30, 2008 at 5:07 PM, Rob Riggen [EMAIL PROTECTED] wrote:
 Surely you don't do that on every call?
 
 I'm using Zend_Db_Table so I'm not necessarily writing queries - where
 can/should this be done?
 
 Thanks!
 
 Rob
 
 
 On Tue, Sep 30, 2008 at 5:04 PM, Bradley Holt [EMAIL PROTECTED]
 wrote:
 Hi Rob - I usually do this by issuing a 'SET NAMES UTF8' query.
 
 
 On Tue, Sep 30, 2008 at 4:59 PM, Rob Riggen [EMAIL PROTECTED] wrote:
 Is there a way to force the character set on mysql db connections to UTF-8?
 
 Thanks,
 
 Rob
 
 
 Robert Riggen - Zend Certified Engineer
 Big Yellow Technologies, LLC
 
 Essex Junction, VT 05452
 802.578.6719 
 [EMAIL PROTECTED]
 
 

-- 
Ralph Schindler
Software Engineer | [EMAIL PROTECTED]
Zend Framework| http://framework.zend.com/