设置编码
void|boolean Driver_Database_Driver_SQLite::set_charset( string $charset )
参数列表
参数 类型 描述 默认值 $charset
string
$charset
void|boolean
public function set_charset($charset)
{
if (!$charset)return;
$connection_id = $this->connection_id();
$connection = Database_Driver_SQLite::$_connection_instance[$connection_id];
if (!$connection_id || !$connection)
{
$this->connect();
$this->set_charset($charset);
return;
}
if (isset(Database_Driver_SQLite::$_current_charset[$connection_id]) && $charset==Database_Driver_SQLite::$_current_charset[$connection_id])
{
return true;
}
$status = (bool)sqlite_query('SET NAMES ' . $this->quote($charset), $connection);
if ($status === false)
{
throw new Exception('Error:' . sqlite_error_string($connection), sqlite_last_error($connection));
}
# 记录当前设置的编码
Database_Driver_SQLite::$_current_charset[$connection_id] = $charset;
}