【发布时间】:2018-02-27 04:27:04
【问题描述】:
我试图在我的Code-Igniter 应用程序中将Array as parameter 传递给Stored Procedure。当我打印该数组时,它会为我提供所选值的正确结果。但它在我的模型函数中给了我一个错误。
这是我的控制器:
public function index()
{
$propertyType=$this->input->post('property_type');
$area=$this->input->post('area_id');
$clustersID['cluster']=$this->input->post('cluster_id');
$stageId=$this->input->post('property_status');
print_r($clustersID);
$data['properties'] = $this->p->getPropertyByAreaCluster($propertyType, $area, $clustersID, $stageId);
// echo "<pre>";
// print_r($data['properties']);
// echo "</pre>";
// exit();
//$data['props'] = $this->p->PropView($propId);
$this->load->view('template/header', $data);
$this->load->view('Property/property_view', $data);
$this->load->view('template/footer');
}
这是我的模型:
public function getPropertyByAreaCluster($propertyType, $area, $clustersID, $stageId)
{
$query = $this->db->query("call fetch_propertyType_Area_Cluster_Stage($propertyType,$area,$clustersID,$stageId)");
if ($query) {
$data = $query->result();
$query->next_result();
$query->free_result();
return $data;
}else{
return false;
}
}
错误:
遇到 PHP 错误 严重性:通知
消息:数组到字符串的转换
文件名:models/Property_m.php
行号:26
回溯:
文件:/opt/lampp/htdocs/livemg/application/models/Property_m.php 行: 26 函数:_error_handler
文件:/opt/lampp/htdocs/livemg/application/controllers/Property.php 行:61 函数:getPropertyByAreaCluster
文件:/opt/lampp/htdocs/livemg/index.php 行:315 功能: 需要一次
发生数据库错误错误号:1054
“字段列表”中的未知列“数组”
调用 fetch_propertyType_Area_Cluster_Stage(0,0,Array,0)
文件名:models/Property_m.php
行号:26
【问题讨论】:
-
尝试使用 var_dump() 将 clusterId 打印到函数中
-
在哪里?在控制器或模型函数中。
-
进入模型函数
-
感谢您的回复,得到答复。
-
欢迎。好.. :)
标签: php codeigniter parameters codeigniter-3