Skip to content

Commit

Permalink
Make optional the database charset setting
Browse files Browse the repository at this point in the history
  • Loading branch information
horrabin committed Dec 7, 2015
1 parent b5c19cd commit 4ddbaba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/local.config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $CONFIG_VARS['db_server'] = array(
'dbname'=>'opendb', //OpenDb database name
'username'=>'lender', //OpenDb database user name
'passwd'=>'test', //OpenDb user password
'charset'=>'utf8', //Database charset
//'charset'=>'utf8', //Database charset (OPTIONAL)
'table_prefix'=>NULL, //'opendb_';//Specify a table prefix. Include the '_' as well!
'debug-sql'=>FALSE); //Specify whether all SQL statements should be displayed in the page.

Expand Down
5 changes: 2 additions & 3 deletions lib/database/mysql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@param $cache_link - if TRUE, save reference to link for reuse.
*/
function db_connect($host, $user, $passwd, $dbname, $charset, $cache_link = TRUE) {
function db_connect($host, $user, $passwd, $dbname, $charset = NULL, $cache_link = TRUE) {
global $_opendb_dblink;

$link = @mysql_connect($host, $user, $passwd);
Expand All @@ -42,8 +42,7 @@ function db_connect($host, $user, $passwd, $dbname, $charset, $cache_link = TRUE
if ($cache_link) {
$_opendb_dblink = $link;
}
@mysql_query("SET NAMES '.$charset.'");
echo "HOLA";
if ($charset!=NULL) @mysql_query("SET NAMES '.$charset.'");
return $link;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/database/mysqli.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@param $cache_link - if TRUE, save reference to link for reuse.
*/
function db_connect($host, $user, $passwd, $dbname, $charset, $cache_link = TRUE) {
function db_connect($host, $user, $passwd, $dbname, $charset = NULL, $cache_link = TRUE) {
global $_opendb_dblink;

$index = strpos($host, ':');
Expand Down Expand Up @@ -64,7 +64,7 @@ function db_connect($host, $user, $passwd, $dbname, $charset, $cache_link = TRUE
$_opendb_dblink = $link;
}

@mysqli_set_charset($link, $charset);
if ($charset!=NULL) @mysqli_set_charset($link, $charset);

return $link;
}
Expand Down

0 comments on commit 4ddbaba

Please sign in to comment.