简体   繁体   中英

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

I've created the table config with the default structure (from 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?

Config::get('DB.my_unique_indentifier') doesn't seem to work...

Ok, so the config.config field (MySQL) needs to be a serialized array when using the .db extension!


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. This will may be implemented in FuelPHP 1.8 version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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