php - Zend_Auth_Adapter_DbTable UTF-8


Here is how I am getting an identity from a database:

$adapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'));
// etc

$client = $adapter->getResultRowObject(null, array('password_hash'));
// store client object in the session
$authStorage = $auth->getStorage();

The problem with this is that the getResultRowObject() returns an object with messed up diacritics. My database has UTF-8 encoding as well as all my tables.

So instead of:


I get:


This is how I am creating the db adapter:

protected function _initDb()
    $this->configuration = new Zend_Config_Ini(APPLICATION_PATH
                                               . '/configs/application.ini',
    $this->dbAdapter = Zend_Db::factory($this->configuration->database);
    $stmt = new Zend_Db_Statement_Pdo($this->dbAdapter,
                                      "SET NAMES 'utf8'");



You can add in your config.ini acharset param, so no need to executeSET NAMES on your own. I have something like this in all my ini's and works fine:

resources.db.adapter = mysqli = localhost
resources.db.params.username = user
resources.db.params.password = pass
resources.db.params.charset = utf8
resources.db.params.dbname = db

People are also looking for solutions to the problem: PHP RMI for a class


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.