CodeIgniter 辅助函数可以使用数据库函数吗?
我的一个 CodeIgniter 控制器函数需要调用递归函数作为其功能的一部分.如果我把它放在控制器类中,函数调用就会阻塞,如果我把它放在类之外,它就不能访问数据库函数 ($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..
相关文章