控制器文件。
public function insert()
{
$data = array(
'vndr_name' => $this->input->post('vndr_name'),
'vndr_phone' => $this->input->post('vndr_phone'),
'vndr_mobile' => $this->input->post('vndr_mobile'),
'vndr_gst' => $this->input->post('vndr_GST'),
'vndr_pan' => $this->input->post('vndr_PAN'),
'vndr_addressLine1' => $this->input->post('vndr_addr_line1'),
'vndr_addressLine2' => $this->input->post('vndr_addr_line2'),
'vndr_city' => $this->input->post('vndr_city'),
'vndr_state' => $this->input->post('vndr_state'),
'vndr_zipcode' => $this->input->post('vndr_ZIP'),
'vndr_enrldate' => $this->input->post('enrlmnt_date')
);
$udata = $this->Vendor_model->insert($data);
//print_r($udata);
if($udata !== 0)
{
//print_r("$udata");
echo 'success';
exit;
}
else
{
echo 'failed';
exit;
}
}
模型文件,因为我要先插入值,所以我没有使用OUT参数。如果参数是数组变量,是否还有其他方法可以调用存储过程。
class Vendor_model extends CI_Model {
public function insert($id)
{
//$this->db->query("CALL sp_select_vendor()");
//$userlevel = $this->db->insert('tbl_Vendor', $id);
$userlevel= $this->db->query("CALL sp_insert_vendor()");
return $userlevel;
if($userlevel->num_rows() > 0)
{
$row = $userlevel->row();
return $row;
}
else
{
return $userlevel->num_rows();
}
}
存储过程文件
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_insert_vendor`(IN vname LONGTEXT, IN vphone LONGTEXT, IN vmobile LONGTEXT, IN vgst LONGTEXT, IN vpan LONGTEXT, IN vadd1 LONGTEXT, IN vadd2 LONGTEXT, IN vcity LONGTEXT, IN vstate LONGTEXT, IN vzip LONGTEXT, IN vedate LONGTEXT)
BEGIN
INSERT INTO tbl_Vendor (vndr_name,vndr_phone,vndr_mobile,vndr_gst,vndr_pan,vndr_addressLine1, vndr_addressLine2, vndr_city, vndr_state,vndr_zipcode, vndr_enrldate) VALUES (vname,vphone,vmobile,vgst, vpan,vadd1,vadd2,vcity, vstate, vzip, vedate);
END$$
DELIMITER ;
答案 0 :(得分:0)
好吧...您可以先$ this-> db-> escape()解析字符串。
this.Add.push({add:"102,ajaynagar", loc: "andheri"});