是否可以在活动查询中添加子字符串?

我有这个示例,当我用纯sql将其写出时,它可以工作。但是,当我在CI中的活动查询中编写它时,结果不会显示。我想知道是否有人可以帮助验证这是否正确。

        $this->db->distinct();
        $this->db->select('user_table.id','user_table.first_name','user_table.last_name','user_table.email','user_table.created_on');
        $this->db->from($this->user_table);
        $this->db->join($this->account_items_table,'user_accounts.id = account_items.user_id','LEFT');
        $this->db->where('SUBSTRING(account_items.key,1,2)',$input);

最佳答案

CI可能在表达式周围添加反引号,并在where()中将第三个参数传递为false

$this->db->where('SUBSTRING(account_items.key,1,2)',$input,false);

关于php - 在CodeIgniter Where子句中添加子字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48079430/

10-14 13:09
查看更多