选择语言 :

 Driver_Database_Driver_SQLite::set_charset

设置编码

void|boolean Driver_Database_Driver_SQLite::set_charset( string $charset )
throws
Exception

参数列表

参数 类型 描述 默认值
$charset string $charset
返回值
  • void|boolean
File: ./drivers/database/sqlite/sqlite.class.php
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
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;
}