问题在codeIgniter中 [英] problem with where in codeIgniter
本文介绍了问题在codeIgniter中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果使用此代码,显示所有数据,所有名称和所有ids。我要做什么?
i使用codeIgniter
尊重
if use of this code, show me all data, all names and all ids. what do i do?
i use of codeIgniter
With respect
$search_customer = 1;//$this->input->post('search_customer');
$where = "id=$search_customer OR name=$search_customer";
$query = $this->db->get('customer');
$this->db->where('id', $search_customer);
$this->db->or_where('name', $search_customer);
if($query->num_rows()==0){
echo '0';
}else{
$data = array();
foreach ($query->result() as $row)
{
$data[] = $row;
}
echo json_encode($data);
}
推荐答案
$query = $this->db->get('customer');
。
您可能想要
before you have set your where clauses. You probably want
$this->db->where('id', $search_customer);
$this->db->or_where('name', $search_customer);
$query = $this->db->get('customer');
如果您仍然遇到问题,请查看正在生成/运行的sql:
If you are still having problems take a look at the sql being generated/run:
echo $this->db->last_query();
这篇关于问题在codeIgniter中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文