【发布时间】:2016-12-28 08:15:55
【问题描述】:
我正在尝试将数组从 codeIgnitor 中的控制器传递给模型我知道这个问题有一些答案,但我尝试了所有答案,但没有任何解决方案适用于我。所以这是我的代码:
控制器:
<?php
if(! defined('BASEPATH')) exit('No direct script access allowed');
class SearchController extends CI_Controller{
var $controller = "user";
public function index(){
$this->home();
}
public function home(){
$this->load->view("search_view");
}
public function search(){
if(isset($_POST['submit'])){
$data['type']=$this->input->post('type');
$data['value']=$this->input->post('value');
$this->load->model("SearchModel");
$this->load->SearchModel->getCadre($data);
}
}
}
?>
型号:
<?php
class SearchModel extends CI_Model{
function construct(){
parent::__construct();
$this->getCadre();
}
function getCadre(){
$query = $this->db->get('cadres');
$query = $this->db->where($type,$value);//the argument witch i want to take from array
if($query->num_rows()>0){
$values = result();
return $query->result();
}
else{
return NULL;
}
}
}
?>
【问题讨论】:
-
嗨,你能把日志错误贴出来吗?
标签: php codeigniter model-view-controller model