CodeIgniter 辅助函数可以使用数据库函数吗? [英] Can CodeIgniter Helper Functions use database functions?

查看:30
本文介绍了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..

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

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