我已经编写了一个 codeigniter 模型函数,但是在 php 7 中出现语法错误.. 请你建议我更改
在 group by order by 语句附近出错..
我的代码片段:
function listing($searchText = '', $page, $segment)
{
$this->db->select('tr.*,group_concat(tg.groundname) as grplist ');
$this->db->from('tb_tournament as tr ');
$this->db->join('tournamentground as tg', 'tr.tournamentId=tg.tournamentId', 'left');
$this->db->where('tr.is_deleted','0');
if(!empty($searchText)) {
$likeCriteria = " (tr.organizerName LIKE '%".$searchText."%'
OR tr.location LIKE '%".$searchText."%'
OR tr.phone LIKE '%".$searchText."%'
OR tr.email LIKE '%".$searchText."%'
OR tr.level LIKE '%".$searchText."%'
OR tr.gender LIKE '%".$searchText."%')";
$this->db->where($likeCriteria);
}
$this->db->group_by('tr.tournamentId');
$this->db->order_by('tr.tournamentId', 'DESC');
$this->db->limit($page, $segment);
$query = $this->db->get();
$result = $query->result();
//print"<pre>";
//print_r($result);
return $result;
}
您可以在查询中使用以下逻辑:
....
$this->db->or_like('tr.organizerName',$searchText);
$this->db->or_like('tr.location',$searchText);
....
....
完成 :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句