用户
 找回密码
 入住 CI 中国社区
搜索
查看: 941|回复: 1
收起左侧

[版本 3.x] 请教数组的意思

[复制链接]
发表于 2016-11-22 11:08:37 | 显示全部楼层 |阅读模式
一个数据表 students,有几个键值

id   key  number

在controller中,代码如下

PHP复制代码
 
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的代码如下

PHP复制代码
 
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形式,这里该怎么写呢?
发表于 2016-11-22 13:59:58 | 显示全部楼层
那你就需要自己写循环和 if 语句自己过滤数组。

本版积分规则