我有一个控制器,我根据客户端ID和项目ID选择值。 我的控制器是:
$this->data['editval'] = $this->Add_project_m->displayedit($projectid, $clientid)
在模型中代码是
function displayedit($projectid,$clientid){
$this->db->select('client_id,project_name,project_location,square_feet,project_value,delete_display,phone,id,name');
$this->db->where('id', $projectid);
$this->db->where('client_id', $clientid);
$query=$this->db->get('new_project');
return $query->result();
}
我得到一个空数组。欢迎任何帮助。
答案 0 :(得分:0)
请使用$ query-> row()而不是$ query-> result()
答案 1 :(得分:0)
试试这个
function displayedit($projectid,$clientid){
$this->db->select('client_id,project_name,project_location,square_feet,project_value,delete_display,phone,id,name');
$this->db->from('new_project');
$this->db->where('id', $projectid);
$this->db->where('client_id', $clientid);
return $this->db->get()->result_array();
}
答案 2 :(得分:0)
希望以下代码能够正常运行: function displayedit($ projectid,$ clientid){
$this->db->select('client_id,project_name,project_location,square_feet,project_value,delete_display,phone,id,name');
$this->db->from('new_project');
$this->db->where('id', $projectid);
$this->db->where('client_id', $clientid);
$qry=$this->db->get();
return ($qry->num_rows(0)>0)? $qry->result() :false;
}