在PHP CodeIgniter中包含多个要检查的值


public function get_tertiarylevel_present() {
$checker = array(
'timestamp' => strtotime(date('Y-m-d')),
'section_id' => 11,
'status'    => 1
);
$tertiarylevel_present = $this->db->get_where('daily_attendances', $checker);
return $tertiarylevel_present->num_rows();
}

当前正在检查"状态"值1(仅存在)。如何修改还检查数据库是否有"状态"值3(延迟)。如果要检查的值不止一个,如何在数组中包含

您需要使用where_in(https://www.codeigniter.com/userguide3/database/query_builder.html#CI_DB_query_builder::where_in):

这应该可以工作(但还没有测试过):

public function get_tertiarylevel_present() {
$this->db->where('timestamp', strtotime(date('Y-m-d')));
$this->db->where('section_id', 11);
$this->db->where_in('status', array(1, 3));
$tertiarylevel_present = $this->db->get('daily_attendances');
return $tertiarylevel_present->num_rows();
}

where condition array = this

<pre> <code>
$array = array(  'timestamp' => strtotime(date('Y-m-d')),
'section_id' => 11, 
'id >=' => 1
);
</code> </pre>

你应该使用'id>' =>1 .告诉你在什么情况下是指