Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework: How do I plug my procedural solution for cyrillic (russian) chars into my ZF project?
    primarykey
    data
    text
    <p>I'm in my first ZF project, and ran into a brick wall with russian characters. (see <a href="https://stackoverflow.com/questions/8392863/php-cyrillic-russian-chars-are-echoing-as-question-marks-why">my original post on StackOverflow here</a>) I switched to simple old procedural PHP to troubleshoot it, and now I can use a little help in getting my solution implemented into my ZF project.</p> <pre><code>// in application.ini resources.db.adapter = pdo_mysql resources.db.params.host = localhost resources.db.params.username = user resources.db.params.password = pass resources.db.params.dbname = db resources.db.params.charset = UTF8 resources.db.params.driver_options.1002 = "SET NAMES utf8" // in bootstrap public function initDb(){ // For Testing ----&gt; /* Configures PDO to execute the 'SET NAMES UTF8;' SQL query just before any other query. If no query is executed on your page, this will not be executed. */ $pdoParams = array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES UTF8;'); $params = array( 'host' =&gt; 'localhost', // TODO: get from application.ini 'username' =&gt; 'user', // TODO: get from application.ini 'password' =&gt; 'pass', // TODO: get from application.ini 'dbname' =&gt; 'db', // TODO: get from application.ini 'driver_options' =&gt; $pdoParams ); try { $db = Zend_Db::factory('PDO_MYSQL', $params); Zend_Db_Table_Abstract::setDefaultAdapter($db); } catch (Exception $e) { exit($e-&gt;getMessage()); } Zend_Registry::set('dbAdapter', $db); } // my data table gateway class Model_DbTable_Books extends Zend_Db_Table_Abstract { protected $_name = 'book'; protected $_primary = 'id'; } // my controller action public function listAction(){ $DbTableBooks = new Model_DbTable_Books(); $this-&gt;view-&gt;allBooks = $DbTableBooks-&gt;fetchAll(); } // my view script echo'&lt;pre&gt;'; print_r($this-&gt;allBooks); echo'&lt;/pre&gt;'; // For Testing ----&gt; </code></pre> <p><strong>[UPDATE]</strong></p> <p>Here's the SQL for my table:</p> <pre><code>CREATE TABLE IF NOT EXISTS `book` ( `id` int(3) unsigned NOT NULL AUTO_INCREMENT, `parentID` int(3) unsigned DEFAULT NULL, `russian` varchar(24) NOT NULL, `english` varchar(24) NOT NULL, PRIMARY KEY (`id`), KEY `parentId` (`parentID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3; INSERT INTO `book` (`id`, `parentID`, `russian`, `english`) VALUES (1, 0, 'Мэри имела', 'Mary had'), (2, 0, 'Небольшой ягненок', 'a little lamb'); </code></pre> <p>And here's the procedural code which works:</p> <pre><code>/* SANDBOX */ if(!$link = mysql_connect('localhost','user','pass')) die('Could not connect: ' . mysql_error()); mysql_set_charset('UTF8',$link); if (!$db = mysql_select_db('db', $link)) die ("Can't use $_DB : " . mysql_error()); $result = mysql_query('SELECT * FROM book'); while($row = mysql_fetch_assoc($result)) { echo'&lt;pre&gt;';print_r($row);echo'&lt;/pre&gt;'; // For Testing ----&gt; } mysql_close($link); </code></pre> <p><strong>[/UPDATE]</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload