我需要运行与条件的查询 where和 or_where使用笨相同的字段。有操作执行其他字段的地方。编码,
function get_newTapal($off, $status)
{
$p = $this->db->select('*')
->from('tbl_tapal')
->join('tbl_subjectmain', 'tbl_subjectmain.Msub_Cd = tbl_tapal.Tmain_sub')
->join('tbl_subject_all', 'tbl_subject_all.Sub_Cd = tbl_tapal.Tsub_sub')
->join('tbl_seat', 'tbl_seat.SeatCd = tbl_tapal.Tseat')
->where('tbl_tapal.Tstatus', $status)
->where('tbl_tapal.Toffice_id', $off)
->where('tbl_tapal.Tmain_sub !=', 1)
->where('tbl_tapal.Tsub_sub !=', 2)
->or_where('tbl_tapal.Tstatus', 2)
;
$query = $p->get();
$new_tapal=$query->result();
foreach($new_tapal as $row){ echo $row->Toffice_id.'/'.$row->Tapal_no.'/'.$row->Tyear.'<br>'; }
}
Run Code Online (Sandbox Code Playgroud)
当我在没有or_where条件的情况下运行查询时, 它会根据代码正常工作。我需要满足where状态值为“1”或“2”的所有条件的行 。但是当我添加 or_where条件时,它不会检查查询那部分的其他条件。即,查询返回满足前 4 个where条件的行加上仅满足 条件的行 or_where。
有人可以帮我吗?
您可以$this->db->or_where_in()用于检查其中的倍数或条件。
前任:
$status= array('1', '2', '3');
$this->db->or_where_in('tbl_tapal.Tstatus', $status);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3308 次 |
| 最近记录: |