简体   繁体   English

FuelPHP-如何在MySQL表中使用Config :: get($ item)?

[英]FuelPHP - How to use Config::get($item) with a MySQL table?

I've created the table config with the default structure (from FuelPHP doc) 我已经使用默认结构创建了表config (来自FuelPHP doc)

CREATE TABLE IF NOT EXISTS `config` (
  `identifier` char(100) NOT NULL,
  `config` longtext NOT NULL,
  `hash` char(13) NOT NULL,
  PRIMARY KEY (`identifier`)
)

but now, how can I access to that in my php code? 但是现在, 如何在我的php代码中访问它呢?

Config::get('DB.my_unique_indentifier') doesn't seem to work... Config::get('DB.my_unique_indentifier')似乎不起作用...

Ok, so the config.config field (MySQL) needs to be a serialized array when using the .db extension! 好的,因此在使用.db扩展名时, config.config字段(MySQL)需要为序列化数组!


to load from the database: 从数据库加载:

Config::load('visio.db'); // where visio is the config key.

to save a new config: 保存一个新的配置:

Config::save('visio.db', array('my_param' => 'my_value'));

Here's my way to play with it: 这是我的玩法:

$config = Config::load('visio.db');
$jetons =& $config['jetons'];

$jetons += 10;
Debug::dump($jetons);
$config = Config::save('visio.db', $config);

Using Config::load('visio.my_param.db') doesn't work yet. 使用Config::load('visio.my_param.db')尚无法使用。 This will may be implemented in FuelPHP 1.8 version. 这可能会在FuelPHP 1.8版本中实现。

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

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