如何在Codeigniter查询中找到非ASCII字符?

时间:2018-12-12 08:35:56

标签: php mysql codeigniter-3

我为mysql尝试过的以下查询,它工作正常,但我需要以codeigniter活动记录类的形式进行查询。

SELECT name FROM tblmarkets_football WHERE name <> CONVERT(name USING ASCII);

我尝试了类似的方法,但是它不起作用,出现500错误....

$wherestr = 'tblmarkets_football.name <>'. CONVERT(tblmarkets_football.name. ' USING ASCII');
$this->db->select('*');
$this->db->from('tblmarkets_football');
$this->db->join('tblmarkets','tblmarkets.id = tblmarkets_football.market_id','left');
$this->db->where($wherestr);

1 个答案:

答案 0 :(得分:0)

如果您在转义时在条件&WHERE中传递了NULL值,则Active Record允许在FALSE中使用自定义字符串。

$wherestr = 
   'tblmarkets_football.name <> CONVERT(tblmarkets_football.name USING ASCII)' );
$this->db->where( $wherestr, NULL, FALSE );

请参阅有关->where()方法的文档: https://www.codeigniter.com/userguide3/database/query_builder.html#looking-for-specific-data