for 发表于 2016-11-22 11:08:37

请教数组的意思

一个数据表 students,有几个键值

id   keynumber

在controller中,代码如下


function list_post()
{
header('Content-type: application/json');
$postkey = $this->post('postkey');
$data = array('key'=>$postkey);
$select_query = $this->list_model->list($data);
if ($select_query)
{

}
else
{

}
}



list model的代码如下


function list($data)
{
        $query = $this->db->get_where('students',$data);
        return $query->result_array();
}



列出了students表中所有的key的值为传过来的postkey的学生数据,那么我想实现,列出所有的key为postkey或者 number为postkey的所有数据
sql就是 select * from students where key = postkey or number = postkey,不用sql语句的话,用array形式,这里该怎么写呢?

Hex 发表于 2016-11-22 13:59:58

那你就需要自己写循环和 if 语句自己过滤数组。
页: [1]
查看完整版本: 请教数组的意思