【发布时间】:2015-05-15 19:34:59
【问题描述】:
我想问一下你们中是否有人知道如何在 codeigniter 中的 where 中放置 or_where?
我想创建如下所示的查询
select *
from table
where
(
(in = 0 and call_in = 1) or
(out = 0 and call_out = 1)
) and
mid = 0
ORDER BY id DESC
limit 1
我创造了这样的东西
$result = $mysql_handler->select('*')
->from("table")
->where(
array(
"in" => 0,
"call_in" => 1
)
)
->or_where(
array(
"out" => 0,
"call_out" => 1
)
)
->where("mid", 0)
->order_by("id", "DESC")
->limit(1)
->get();
但我知道这是不对的,因为这段代码会产生这样的结果
select *
from table
where
(in = 0 and call_in = 1) or
(out = 0 and call_out = 1) and
mid = 0
ORDER BY id DESC
limit 1
我想将 or_where 放在 where 子句中,但我不确定这是否正确或如何做。请指教谢谢。
【问题讨论】:
标签: php mysql codeigniter