Codeigniter多选查询

时间:2015-01-03 11:11:26

标签: mysql codeigniter

我试图从mysql查询

进行codeigniter查询

我的mysql查询是:

select * 
from class_routine 
where 
  semester='$semester' 
  and day='$day' 
  and time_schedule='$time_schedule' 
  and (batch='$batch' or section='$section' or teacher='$teacher' or room='$room');

以上查询什么是codeigniter查询?

我将在模型中使用此查询。

1 个答案:

答案 0 :(得分:0)

首先,您应该考虑查看Documentation 之前提出任何问题,然后指定您查看的内容以及您尝试过的内容,发布您的代码。

无论如何,试试这个让我知道:

$this->db->where(array('semester' => $semester, 'day' => $day, 'time_schedule' => $time_scehdule));
$this->db->where("batch = $batch OR section = $section OR teacher = $teacher OR room = $room", NULL, FALSE);
$result = $this->db->get('class_routine')->result();

如果怀疑使用普通查询是完全安全的:

$result = $this->db->query("SELECT * FROM ....")->result();