为什么我的CodeIgniter查询总是返回num_rows> 0?

时间:2011-08-02 00:00:56

标签: php codeigniter where

  

可能重复:
  problem with where in codeIgniter

为什么输入那个空时显示数据库‘customer’中的所有数据? 我希望输入为空num_rows == 0

search_customer = 1;//$this->input->post('search_customer');
$query = $this->db->where('id', $search_customer)->or_where('name', $search_customer)->get('customer'); 
if($query->num_rows()==0){
                echo '0';
            }else{
                $data = array();
                foreach ($query->result() as $row)
                {
                   $data[] = $row;
                }
                echo json_encode($data);
            } 

0 个答案:

没有答案