我正在尝试对代码点火器执行此sql查询
SELECT* FROM person WHERE type = 'staff' AND description LIKE 'university%'
我不确定它是否正确。。。
$this->db->get_where('person' , array('type'=>'staff'))
->like('description','university%')
->result_array();
有人知道我的案子吗?提前感谢。。。
使用活动记录可以执行
$query = $this->db->select('*')
->from('person')
->where('type','staff')
->like('description','university','after')
->get();
$result = $query->result_array();
确保您将after
作为like()
函数中的第三个参数传递,这样活动记录将在university
之后添加通配符,即%
,这样它看起来就像LIKE 'university%'
文档对此解释得很好,但他们的API非常简单。要生成查询,您需要如下所示的相关代码:
$this->db->select('*')
->from('person');
->where('type', 'staff')
->like('description','university');
$query = $this->db->get();
$result = $query->result_array();
我从未使用过链接(尽管我知道这是可能的),但分解你的问题应该很容易;
$this->db->from('person');
$this->db->where('type','staff');
$this->db->where('description', 'university%');
$query = $this->db->get();
$result = $query->result_array();
return $result;