CodeIgniter帮助程序功能可以使用数据库功能吗? [英] Can CodeIgniter Helper Functions use database functions?

查看:48
本文介绍了CodeIgniter帮助程序功能可以使用数据库功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的CodeIgniter Controller函数之一需要调用递归函数作为其功能的一部分。如果我将其放入控制器类中,该函数调用就会阻塞,如果我不能访问数据库函数($ this-> db-> get())放在课外

One of my CodeIgniter Controller functions needs to call a recursive function as part of its functionality. The function call chokes if I put it inside the controller class, and it can't access database functions ($this->db->get()) if I put it outside the class. Would making it a helper function fix this problem?

推荐答案

您可以获取实例:

 $CI =& get_instance();

此后,您将可以使用 $ CI-> db 进行查询。

After that you will be able to use $CI->db for queries..

这篇关于CodeIgniter帮助程序功能可以使用数据库功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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