在相同的函数中获取 num_rows 和 result() 数据并传递到 codeigniter 中的控制器数据
Get num_rows and result() data in same function and past to controller data in codeigniter
我试图向用户展示数据库中的内容,并询问他是否仍要插入他输入的信息,但我正在努力将他们的数据传送到我的控制器。
这是我目前拥有的:
控制器
$result = $this->call_model->checkCallExists($callInfo);
if($result == true) {
型号
function checkCallExists($callInfo)
{
//pre($callInfo);
//die;
$this->db->select("*");
$this->db->from("tbl_calls");
$this->db->where("type_of_equipment", $callInfo['type_of_equipment']);
$this->db->where("fk_location_id", $callInfo['fk_location_id ']);
$this->db->where("fk_status_id", $callInfo['fk_status_id ']);
$query = $this->db->get();
if ($query->num_rows() > 0){
$retun_array['data']= $query->result_array();
return false;
}
else{
return true;
}
}
这是我在模型中进行转储时得到的结果
我想以 table 形式显示它,并带有一个按钮以取消或插入数据库,但我没有将数据发送到我的控制器。
提前谢谢你。
您 return判断“真”或“假”。结果数组
而不是“真”return
型号:
if ($query->num_rows() > 0){
$return_array['data']= $query->result_array();
return $return_array;
}
else{
// no records found
return false;
}
或更短:
return ($query->num_rows())? $query->result_array():false;
控制器:
$result = $this->call_model->checkCallExists($callInfo);
if($result){
echo'<pre>';print_r($result);die; //comment this line to continue
// send data to view
$this->load->view('your_view', $result)
}
我试图向用户展示数据库中的内容,并询问他是否仍要插入他输入的信息,但我正在努力将他们的数据传送到我的控制器。
这是我目前拥有的:
控制器
$result = $this->call_model->checkCallExists($callInfo);
if($result == true) {
型号
function checkCallExists($callInfo)
{
//pre($callInfo);
//die;
$this->db->select("*");
$this->db->from("tbl_calls");
$this->db->where("type_of_equipment", $callInfo['type_of_equipment']);
$this->db->where("fk_location_id", $callInfo['fk_location_id ']);
$this->db->where("fk_status_id", $callInfo['fk_status_id ']);
$query = $this->db->get();
if ($query->num_rows() > 0){
$retun_array['data']= $query->result_array();
return false;
}
else{
return true;
}
}
这是我在模型中进行转储时得到的结果
我想以 table 形式显示它,并带有一个按钮以取消或插入数据库,但我没有将数据发送到我的控制器。
提前谢谢你。
您 return判断“真”或“假”。结果数组
而不是“真”return型号:
if ($query->num_rows() > 0){
$return_array['data']= $query->result_array();
return $return_array;
}
else{
// no records found
return false;
}
或更短:
return ($query->num_rows())? $query->result_array():false;
控制器:
$result = $this->call_model->checkCallExists($callInfo);
if($result){
echo'<pre>';print_r($result);die; //comment this line to continue
// send data to view
$this->load->view('your_view', $result)
}