|
楼主 |
发表于 2015-4-14 19:37:17
|
显示全部楼层
本帖最后由 csfhc 于 2015-4-14 19:44 编辑
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.1.1',
'username' => 'sa',
'password' => '1',
'database' => 'test',
'dbdriver' => 'mssql',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
控制器是这样写的:
class Dbtest extends CI_Controller {
public function get_data()
{
$this->load->database();
$query = $this->db->query('select top 10 * from my_table');
$rows = $query->result();
foreach($rows as $row)
{
echo $row->my_column.'<br>';
}
}
}
访问时提示:
A Database Error Occurred
Unable to set client connection character set: utf8
我用的PHP是5.2.14,不知是不是由于版本低引起的。
|
|