gpt4 book ai didi

codeigniter - 如何在 codeigniter 中的同一字段上使用多个 or_where

转载 作者:行者123 更新时间:2023-12-04 02:08:56 32 4
gpt4 key购买 nike

我需要使用 codeigniter 在同一字段上运行条件为 whereor_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>'; }
}

当我在没有 or_where 条件的情况下运行查询时,它会根据代码正确运行。我需要满足状态值为“1”或“2”的所有 where 条件的行。但是当我添加 or_where 条件时,它不会检查查询那部分的其他条件。即,查询返回同时满足前 4 个 where 条件的行以及仅满足 or_where 条件的行。
有人可以帮我解决这个问题吗?

最佳答案

您可以使用 $this->db->or_where_in() 来检查 where 中的倍数或条件。

例如:

$status= array('1', '2', '3');
$this->db->or_where_in('tbl_tapal.Tstatus', $status);

关于codeigniter - 如何在 codeigniter 中的同一字段上使用多个 or_where,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20835258/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com