DB Charset e Collate
MaxKurama opened this issue · comments
Not an issue... is a suggest
I want to suggest a db charset and collate setting.
directory.php
define('WEBSITE', sprintf('%s/', $website));
db.php
$db['default']['dbcharset'] = 'utf8'; // what developer need
$db['default']['dbcollate'] = 'utf8_unicode_ci'; // what developer need
DB.php
static function get_instance($link_name = null)
{
if (!$link_name) $link_name = self::$default_link_name;
if (!isset(self::$obj_instance_list[$link_name])) {
self::$obj_instance_list[$link_name] = new self;
self::$obj_instance_list[$link_name]->_connect($link_name);
include sprintf('%s%sconfig/%s', BASE_DIR, WEBSITE, self::$config_file);
extract($db[$link_name]);
self::$obj_instance_list[$link_name]->query(sprintf("SET NAMES '%s' COLLATE '%s'", $dbcharset, $dbcollate));
}
self::$obj_instance_list[$link_name]->fetch_mode = self::$default_fetch_mode;
return self::$obj_instance_list[$link_name];
}
I´m using rain framework and like it so much.
I have a few suggestions to improve performance...
- Use single quote only
- Use sprintf not concatenate
Hey Kurama,
thanks for your great suggestions for the collation. About the performance improvements you can take a look to these benchmarks,
double and single quotes are equivalent:
http://phpbench.com/
About sprintf to concatenate I never run a bench on that, but in my
experience the bottle neck are the DB, the I/O, the access to the file
system and the streaming (Curl), so it's not worth to improve the speed of a
small function if that involve to make the code less readable.
Best,
Federico
On Wed, Sep 21, 2011 at 11:39 PM, MaxKurama <
reply@reply.github.com>wrote:
Not an issue... is a suggest
I want to suggest a db charset and collate setting.
directory.php
define('WEBSITE', sprintf('%s/', $website));db.php
$db['default']['dbcharset'] = 'utf8'; // what developer need
$db['default']['dbcollate'] = 'utf8_unicode_ci'; // what developer needDB.php
static function get_instance($link_name = null)
{
if (!$link_name) $link_name = self::$default_link_name;
if (!isset(self::$obj_instance_list[$link_name])) {
self::$obj_instance_list[$link_name] = new self;
self::$obj_instance_list[$link_name]->_connect($link_name);
include sprintf('%s%sconfig/%s', BASE_DIR, WEBSITE,
self::$config_file);
extract($db[$link_name]);
self::$obj_instance_list[$link_name]->query(sprintf("SET NAMES
'%s' COLLATE '%s'", $dbcharset, $dbcollate));
}
self::$obj_instance_list[$link_name]->fetch_mode =
self::$default_fetch_mode;
return self::$obj_instance_list[$link_name];
}Im using rain framework and like it so much.
I have a few suggestions to improve performance...
- Use single quote only
- Use sprintf not concatenate
Reply to this email directly or view it on GitHub:
#3
Hi Federico.
Thanks for all and for you great job.
I´m an optimization obsessed too and cause this I´m using rain framework in my small and big projects
;)
Max
Great, if you see anything that can be improved you can give your
contribution also directly on github,
where the project is shared open source to everybody because of it
;)
--
Federico Ulfo http://www.federicoulfo.it/
Certified Developer Google & PHP
http://www.federicoulfo.it/
On Thu, Sep 22, 2011 at 1:06 PM, MaxKurama <
reply@reply.github.com>wrote:
Hi Federico.
Thanks for all and for you great job.
Im an optimization obsessed too and cause this Im using rain framework in
my small and big projects
;)Max
Reply to this email directly or view it on GitHub:
#3 (comment)
Thanks again...
Could you tell me about maintenance of source and supervision?
You accept any coders and any part of code that any user commit?
How about translate site and doc to pt_BR?
How can I contribute more effectively?
Thanks.
Hey Max,
thanks for your interest, the project is maintained by the RainTM any
contributions on the project are welcome, but we accept only commit
that improve the code
On Sep 24, 2011, at 3:48 PM, MaxKurama
reply@reply.github.com
wrote:
Thanks again...
Could you tell me about maintenance of source and supervision?
You accept any coders and any part of code that any user commit?How about translate site and doc to pt_BR?
How can I contribute more effectively?
Thanks.
Reply to this email directly or view it on GitHub:
#3 (comment)