【发布时间】:2020-01-08 10:10:39
【问题描述】:
我想在我的 MySQL 数据表视图中为用户 = 4 选择 p_code=10 & p_code=24 的记录。我使用了以下代码片段。
$usr = $this->session->userdata('id_user');
if($usr == 4)
{
$this->datatables->where('tbl_officer.p_code', 10);
$this->datatables->where('tbl_officer.p_code', 24);
} else {
$this->datatables->where('tbl_officer.usr', $usr);
}
但是代码输出了一个空结果。如果我删除该行, $this->datatables->where('tbl_officer.p_code', 24);结果仅显示 p_code=10 的官员。
如何在我的代码中添加这两行与 where 子句?有人可以帮忙吗?
【问题讨论】:
标签: mysql codeigniter