使用codeIgniter存储过程 [英] Stored Procedures using CodeIgniter

查看:283
本文介绍了使用codeIgniter存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您就如何使用codeIgniter框架来执行存储过程的建议?我看着用户指南,是唯一能够找到办法利用查询或ActiveRecords来访问数据库。鸭preciate如果有人可以帮助在最早的。

Can you please advice on how to execute a stored procedure using the CodeIgniter Framework? I looked into the User Guide and was only able to find ways to access the DB using queries or ActiveRecords. Appreciate if someone could assist at the earliest.

推荐答案

您可以使用 $这个 - > DB->查询(呼叫my_stored_proc(ARG1,ARG2); )

如果您有out参数,你必须把它包在一个事务中,像这样:

if you have out parameters you have to wrap it in a transaction like so:

$this->load->database();
$this->db->trans_start();

$success = $this->db->query("call my_stored_proc('arg1','arg2',@out_param);");
$out_param_query = $this->db->query('select @out_param as out_param;');

$this->db->trans_complete();

$out_param_row = $this->db->row();
$out_param_val = $this->out_param;

这篇关于使用codeIgniter存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆