Set the character set before making a connection

Ideally the character set should be set with the connection, and so this is
exactly what's being done now.

And now the character set code is attempted to be generalised.
This commit is contained in:
Alexei Sorokin
2020-09-16 19:34:49 +03:00
parent c2508f8fa2
commit aed2344bd4
9 changed files with 118 additions and 54 deletions

View File

@@ -39,11 +39,11 @@ END_OF_TRIM_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
require dirname(__FILE__) . '/sphinx-utils.php';
$base = $base ?? '/usr/local';
$timestamp = date('r');
print <<<END
echo <<<END
#
# Sphinx configuration for StatusNet
# Sphinx configuration for GNU social
# Generated {$timestamp}
#
@@ -109,8 +109,9 @@ function sphinx_template($sn, $table, $query, $query_info)
{
$base = sphinx_base();
$dbtype = common_config('db', 'type');
$charset = common_database_charset();
print <<<END
echo <<<END
#
# {$sn->sitename}
@@ -122,7 +123,7 @@ source {$sn->dbname}_src_{$table}
sql_user = {$sn->dbuser}
sql_pass = {$sn->dbpass}
sql_db = {$sn->dbname}
sql_query_pre = SET NAMES utf8;
sql_query_pre = SET NAMES '{$charset}';
sql_query = {$query}
sql_query_info = {$query_info}
sql_attr_timestamp = created_ts