简体   繁体   English

如何在CodeIgniter中获取迁移配置项?

[英]How to get a migration config item in CodeIgniter?

As usual, to access CodeIgniter's configuration item from a $config array, I would use this function $this->config->item('some_item'); 像往常一样,要从$config数组访问CodeIgniter的配置项,我会使用这个函数$this->config->item('some_item'); . That's fine, but how can I access a config items from this file app/config/migration.php ? 没关系,但是如何从这个文件app/config/migration.php访问配置项呢? where $config['migration_enabled'] is located $config['migration_enabled']所在的位置

I'm doing a $this->config->item('migration_enabled') or $this->config->item('migration_version') , but it returns me always FALSE , anyone know why ? 我正在做$this->config->item('migration_enabled')$this->config->item('migration_version') ,但它总是返回FALSE ,有人知道为什么吗? And how can I work it out to make it accessible within the controller ? 我怎样才能使其在控制器内可访问?

You need to load the migration config before you access it. 您需要在访问之前加载迁移配置。 You can either load it on demand in your controller via: 您可以通过以下方式在控制器中按需加载:

$this->config->load('migration');

or you can autoload it in your config/autoload.php file by adding it to the $autoload['config'] array: 或者你可以在config/autoload.php文件中将它添加到$autoload['config']数组中$autoload['config']它:

$autoload['config'] = array('migration');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM