不确定如何在 Codeigniter 中调用存储过程
Not Sure How to call Store Procedure in Codeigniter
我在调用我的模型中的存储过程时遇到问题,不确定我是否正确执行操作,屏幕显示空白,我是否需要自动加载任何内容才能调用存储过程?
<?php
class Employee_model extends CI_Model
{
public function insert_employee($data)
{
$this->db->insert('employee_list',$data);
return $this->db->insert_id();
}
public function get_employee()
{
$this->db->query("call {storedprocedure Select_employeelist} ");
$query =$this->db->get();
return $query->result();
}
public function delete_employee($id,$data)
{
$this->db->where('id',$id);
$this->db->update('employee_list',$data);
return print_r($data);
}
public function edit_employee($id)
{
$this->db->select('*');
$this->db->from('employee_list');
$this->db->where('id',$id);
$this->db->where('status',1);
$query =$this->db->get();
return $query->result();
}
public function update_employee($data,$id)
{
$this->db->where('id',$id);
$this->db->update('employee_list',$data);
return print_r($data);
}
}
从 codeigniter 调用程序
将 test_proc
视为您的程序。那么应该是
$this->db->query("call test_proc()");
如果你需要发送参数那么
$query = $this->db->query($test_proc,array('id'=>'1','name'=>'test','address'=>'abc'));
然后看结果
print_r($query);
我在调用我的模型中的存储过程时遇到问题,不确定我是否正确执行操作,屏幕显示空白,我是否需要自动加载任何内容才能调用存储过程?
<?php
class Employee_model extends CI_Model
{
public function insert_employee($data)
{
$this->db->insert('employee_list',$data);
return $this->db->insert_id();
}
public function get_employee()
{
$this->db->query("call {storedprocedure Select_employeelist} ");
$query =$this->db->get();
return $query->result();
}
public function delete_employee($id,$data)
{
$this->db->where('id',$id);
$this->db->update('employee_list',$data);
return print_r($data);
}
public function edit_employee($id)
{
$this->db->select('*');
$this->db->from('employee_list');
$this->db->where('id',$id);
$this->db->where('status',1);
$query =$this->db->get();
return $query->result();
}
public function update_employee($data,$id)
{
$this->db->where('id',$id);
$this->db->update('employee_list',$data);
return print_r($data);
}
}
从 codeigniter 调用程序
将 test_proc
视为您的程序。那么应该是
$this->db->query("call test_proc()");
如果你需要发送参数那么
$query = $this->db->query($test_proc,array('id'=>'1','name'=>'test','address'=>'abc'));
然后看结果
print_r($query);