- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要使用 codeigniter 在同一字段上运行条件为 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>'; }
}
当我在没有 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/
我该如何做才能满足以下条件: $this->db->where('msgto.msgto_display', 'y'); $this->db->where('msgto.msgto_unread',
我在 CodeIgniter 上使用 Active Record。我对我应该采取哪种方法感到困惑。目前,我们的登录系统让用户使用用户名/电子邮件以及密码登录。但是我目前的事件记录,如果用户选择使用电子
我正在尝试使用 codeigniter 的事件记录执行以下 SQL 查询: SELECT * FROM USERS_OPTIONS WHERE user_id = 3 AND (option_id =
有没有AR#or_where在 Rails 3 中 User.where(cond1).or_where(cond2) ? 最佳答案 Rails 中没有这样的方法。 我认为在 WHERE 子句中执行
我需要使用 codeigniter 在同一字段上运行条件为 where 和 or_where 的查询。还有其他字段执行操作的地方。代码, function get_newTapal($off, $st
我正在尝试在模型中指定查询 $this->db ->select('*') ->from('library') ->where('library.rat
我有一个查询模型。但是第二个 or_where 不工作 模型 $this->db->select('st_student.st_id'); $this->db->from('st_st
我正在尝试在我的模型中指定一个查询 $this->db ->select('*') ->from('library') ->where('library
我正在尝试将 OR WHERE 查询为可标记行为的查询,就像这样...... Business.tagged_with(params[:query], :any => true) 但我也想同时表演一个
如果我使用单个where,搜索就可以,但是多个where在代码点火器的ajax数据表中不起作用。我使用了不同类型的 where,正如您在注释的代码中看到的那样,除了单个 where 之外,没有任何效果
我正在尝试从数据库中获取一个 result_array(),其中两列必须返回 true,反之亦然,所以我决定使用 or_where 但我的代码是返回 Call to undefined method
我正在使用 CodeIgniter。我需要了解 where 和 or_where 条件如何在 codeigniter 查询生成器中工作。 我需要这样的输出 where a=""AND b=""AND
我有这个代码: $this->db->where('status',1); $this->db->where('category',$category_id); $this->
我是一名优秀的程序员,十分优秀!