mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
MySQL, MySQLi & PostgreSql drivers: default character set is 'utf8' (BC break)
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
* - password (or pass)
|
* - password (or pass)
|
||||||
* - database => the database name to select
|
* - database => the database name to select
|
||||||
* - flags (int) => driver specific constants (MYSQL_CLIENT_*)
|
* - flags (int) => driver specific constants (MYSQL_CLIENT_*)
|
||||||
* - charset => character encoding to set
|
* - charset => character encoding to set (default is utf8)
|
||||||
* - persistent (bool) => try to find a persistent link?
|
* - persistent (bool) => try to find a persistent link?
|
||||||
* - unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
|
* - unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
|
||||||
* - sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
|
* - sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
|
||||||
@@ -74,6 +74,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
DibiConnection::alias($config, 'flags', 'options');
|
DibiConnection::alias($config, 'flags', 'options');
|
||||||
|
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('mysql.default_user');
|
if (!isset($config['username'])) $config['username'] = ini_get('mysql.default_user');
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('mysql.default_password');
|
if (!isset($config['password'])) $config['password'] = ini_get('mysql.default_password');
|
||||||
if (!isset($config['host'])) {
|
if (!isset($config['host'])) {
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
* - database => the database name to select
|
* - database => the database name to select
|
||||||
* - options (array) => array of driver specific constants (MYSQLI_*) and values {@see mysqli_options}
|
* - options (array) => array of driver specific constants (MYSQLI_*) and values {@see mysqli_options}
|
||||||
* - flags (int) => driver specific constants (MYSQLI_CLIENT_*) {@see mysqli_real_connect}
|
* - flags (int) => driver specific constants (MYSQLI_CLIENT_*) {@see mysqli_real_connect}
|
||||||
* - charset => character encoding to set
|
* - charset => character encoding to set (default is utf8)
|
||||||
* - persistent (bool) => try to find a persistent link?
|
* - persistent (bool) => try to find a persistent link?
|
||||||
* - unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
|
* - unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
|
||||||
* - sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
|
* - sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
|
||||||
@@ -75,6 +75,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
|
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('mysqli.default_user');
|
if (!isset($config['username'])) $config['username'] = ini_get('mysqli.default_user');
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('mysqli.default_pw');
|
if (!isset($config['password'])) $config['password'] = ini_get('mysqli.default_pw');
|
||||||
if (!isset($config['socket'])) $config['socket'] = ini_get('mysqli.default_socket');
|
if (!isset($config['socket'])) $config['socket'] = ini_get('mysqli.default_socket');
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
* - host, hostaddr, port, dbname, user, password, connect_timeout, options, sslmode, service => see PostgreSQL API
|
* - host, hostaddr, port, dbname, user, password, connect_timeout, options, sslmode, service => see PostgreSQL API
|
||||||
* - string => or use connection string
|
* - string => or use connection string
|
||||||
* - schema => the schema search path
|
* - schema => the schema search path
|
||||||
* - charset => character encoding to set
|
* - charset => character encoding to set (default is utf8)
|
||||||
* - persistent (bool) => try to find a persistent link?
|
* - persistent (bool) => try to find a persistent link?
|
||||||
* - resource (resource) => existing connection resource
|
* - resource (resource) => existing connection resource
|
||||||
* - lazy, profiler, result, substitutes, ... => see DibiConnection options
|
* - lazy, profiler, result, substitutes, ... => see DibiConnection options
|
||||||
@@ -62,6 +62,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
||||||
if (isset($config['string'])) {
|
if (isset($config['string'])) {
|
||||||
$string = $config['string'];
|
$string = $config['string'];
|
||||||
} else {
|
} else {
|
||||||
|
@@ -45,7 +45,7 @@ echo "</p>\n";
|
|||||||
// connects to MySQL using DSN
|
// connects to MySQL using DSN
|
||||||
echo '<p>Connecting to MySQL: ';
|
echo '<p>Connecting to MySQL: ';
|
||||||
try {
|
try {
|
||||||
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8');
|
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=cp1250');
|
||||||
echo 'OK';
|
echo 'OK';
|
||||||
|
|
||||||
} catch (DibiException $e) {
|
} catch (DibiException $e) {
|
||||||
@@ -65,7 +65,6 @@ try {
|
|||||||
'username' => 'root',
|
'username' => 'root',
|
||||||
'password' => 'xxx',
|
'password' => 'xxx',
|
||||||
'database' => 'dibi',
|
'database' => 'dibi',
|
||||||
'charset' => 'utf8',
|
|
||||||
'options' => array(
|
'options' => array(
|
||||||
MYSQLI_OPT_CONNECT_TIMEOUT => 30
|
MYSQLI_OPT_CONNECT_TIMEOUT => 30
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user