如何从模型/控制器访问CodeIgniter配置变量? [英] How can I access a CodeIgniter configuration variable from a model/controller?
本文介绍了如何从模型/控制器访问CodeIgniter配置变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 /application/config/database.php访问
( CodeIgniter 配置文件),因此我可以 $ db ['default'] ['dbprefix']
I would like to access the $db['default']['dbprefix']
variable from /application/config/database.php
(CodeIgniter configuration file) from within a model so I can write my own queries using the value from the file.
如何做到这一点?
推荐答案
尝试:
$this->load->database();
echo $this->db->dbprefix;
通常你可以使用$ this-> config-> item但是我认为只允许设置变量$ config
Normally you can use $this->config->item but I think that only allows variables set in $config
这篇关于如何从模型/控制器访问CodeIgniter配置变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文