0

我正在使用 CodeIgniter 并希望使用不同的查询返回一些值,我无法更改数据库本身的排序规则,也无法在配置中这样做,因为我正在更改其他人的代码。

有没有办法使用 Active Record 在查询中进行整理?到目前为止,我已经尝试过:

$this->db->select('fieldName COLLATE utf8_bin');

我也尝试过使用$this->db->collator_set_default无济于事。

4

1 回答 1

2

尝试阅读手册 https://codeigniter.com/user_guide/database/configuration.html

在默认连接数组中,您可以找到字段

'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',

运行查询时也可能使用代码

$this->db->query("SET NAMES 'latin1'");
$this->db->insert('table_name', $data);
于 2016-03-22T15:04:37.933 回答