Problems with 'charset' option in db configuration.

View: New views
4 Messages — Rating Filter:   Alert me  

Problems with 'charset' option in db configuration.

by holografix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hii.
This works fine with PHP 5.2.x but not with PHP 5.3.0.

"db" => array(
    'adapter' => 'pdo_mysql',
    "params" => array(
        "host" => 'localhost',
        "username" => 'user',
        "password" => 'xxxxxxx',
        'dbname' => 'dbtest'
        'charset' => 'utf8'

    ),
    "isDefaultTableAdapter" => true
)
           
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in C:\lib\php\ZendFramework\library\Zend\Db\Adapter\Pdo\Mysql.php on line 93           

91    if (!empty($this->_config['charset'])) {
92        $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
93        $this->_config['driver_options'][PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
94    }   

Cheers,
holo


RE: Problems with 'charset' option in db configuration.

by vRandom :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Not sure if this might help but I just read something about the db charset.
 
this page, http://forums.zend.com/viewtopic.php?f=69&p=3535 shows the charset value as "utf-8"
 
Terre 
 
edit: (resent to list, I hate reply vs reply all) 


From: holografix . [mailto:holografix@...]
Sent: Tuesday, June 30, 2009 11:49 AM
To: Nabble Zend Framework General
Subject: [fw-general] Problems with 'charset' option in db configuration.

Hii.
This works fine with PHP 5.2.x but not with PHP 5.3.0.

"db" => array(
    'adapter' => 'pdo_mysql',
    "params" => array(
        "host" => 'localhost',
        "username" => 'user',
        "password" => 'xxxxxxx',
        'dbname' => 'dbtest'
        'charset' => 'utf8'

    ),
    "isDefaultTableAdapter" => true
)
           
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in C:\lib\php\ZendFramework\library\Zend\Db\Adapter\Pdo\Mysql.php on line 93           

91    if (!empty($this->_config['charset'])) {
92        $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
93        $this->_config['driver_options'][PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
94    }   

Cheers,
holo


Re: Problems with 'charset' option in db configuration.

by holografix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
 
I think the problem here is with PHP 5.3.0: Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' . This is not defined in PDO.
Also think utf-8 as charset value is wrong. Issuing SET NAMES utf-8 in mysql command-line raises an error (error 1115). SET NAMES utf8; works fine.
 
Cheers
holo


 
2009/6/30 Terre Porter <tporter@...>
Not sure if this might help but I just read something about the db charset.
 
this page, http://forums.zend.com/viewtopic.php?f=69&p=3535 shows the charset value as "utf-8"
 
Terre 
 
edit: (resent to list, I hate reply vs reply all) 


From: holografix . [mailto:holografix@...]
Sent: Tuesday, June 30, 2009 11:49 AM
To: Nabble Zend Framework General
Subject: [fw-general] Problems with 'charset' option in db configuration.

Hii.
This works fine with PHP 5.2.x but not with PHP 5.3.0.

"db" => array(
    'adapter' => 'pdo_mysql',
    "params" => array(
        "host" => 'localhost',
        "username" => 'user',
        "password" => 'xxxxxxx',
        'dbname' => 'dbtest'
        'charset' => 'utf8'

    ),
    "isDefaultTableAdapter" => true
)
           
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in C:\lib\php\ZendFramework\library\Zend\Db\Adapter\Pdo\Mysql.php on line 93           

91    if (!empty($this->_config['charset'])) {
92        $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
93        $this->_config['driver_options'][PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
94    }   

Cheers,
holo



RE: Problems with 'charset' option in db configuration.

by vRandom :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
> I think the problem here is with PHP 5.3.0: Fatal error: Undefined class
constant 'MYSQL_ATTR_INIT_COMMAND' . This is not defined in PDO.
 
Ah, I see. I don't have PHP 5.3.0 to test with here. I did found a bug
report for this though,  http://bugs.php.net/bug.php?id=47224 

> Also think utf-8 as charset value is wrong. Issuing SET NAMES utf-8 in
mysql command-line raises an error (error 1115). SET NAMES utf8; works fine.

Good to know. I had just read the forum post a minute ago and noticed the
difference in the utf8 vs utf-8.

Terre