mikecao / sparrow

A simple database toolkit for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get and set charset from connection string

opened this issue · comments

The mysql connection string mysqli://user:password@host/database?charset=utf8 allows to add the charset in the query string.

Use $url["query"] in public parseConnection to fetch the query string and look for the charset-parameter using parse_str($url["query"], $array) ... isset($array["charset"]) ...

And apply it to the connection:
$this->getDb()->set_charset(...);
mysql_set_charset(...);