【发布时间】:2015-10-09 17:55:36
【问题描述】:
当我想在 Codeigniter 中编写以下行时:
SELECT * FROM Customers WHERE City LIKE '%es%'; // CONTAINS 'es'
我写了这段代码:
$this->db->select('*');
$this->db->from('Customers');
$this->db->like('City', 'es');
能否请您帮我为以下行编写相关代码:
SELECT * FROM Customers WHERE City LIKE 'ber%'; // STARTS WITH 'ber'
这样它将显示以“ber”开头的城市的信息
【问题讨论】:
-
ellislab.com/codeigniter/user-guide/database/active_record.html
If you want to control where the wildcard (%) is placed, you can use an optional third argument. Your options are 'before', 'after' and 'both' (which is the default).然后$this->db->like('title', 'match', 'after'); // Produces: WHERE title LIKE 'match%' -
现在可以在这里找到使用指南 CI3 codeigniter.com/user_guide/database/… CI2 codeigniter.com/userguide2/database/active_record.html
标签: php sql codeigniter