php - 31.65% of SQL Queries are SET NAME. Is it Necessary? -


looking @ database query statistics, can see 31.65% of sql queries set option. using zend framework 2 pdo extension. not use set option anywhere other in global.php:

'db' => array(             'driver' => 'pdo',             'dsn' => 'mysql:dbname=db;',             'driver_options' => array(                 pdo::mysql_attr_init_command => 'set names \'utf8\''             ),         ), 

the collation of database (mariadb) utf8_general_ci. needed? can remove driver option? cannot defined in database once , all?

you should use option set encoding of each db connection after connection has been created. collation of database quite option not effect encoding of current connection. can miss option if have guarantee mysql server set default work utf8 connections , setting not change without participation (but in case may have problem portability of application). fortunately queries set names ... quite fast.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -