Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
DbConfig - Store your app specific config setting in a DB rather than loads of config files
  • Here's the thing... With this class there is no "root" configuration... so if you simply set DbConfig::set('key', 'string_value') you will have an issue saving... The class assumes that all configuration information is saved into an array. So, in order for autosaving to work it must be an array... Try DbConfig::set('key.subkey', 'value'), this will save the information into an array... or DbConfig::set('key', array('subkey' => 'value')) This may not be the best way to go about this, I'll have to think on whether or not to allow single key -> pair values... I guess it couldn't hurt...
  • hmm i tried DbConfig::set('site.allow_reg','1'); and i get Fuel\Core\Fuel_Exception [ Error ]: DbConfig: value passed to DbConfig::save() must be an array
    PKGPATH/dbconfig/classes/dbconfig.php @ line 103
  • If that doesn't work I'm going to need you to paste the code you're using over to me so I can test. What it seems to be at the moment is that there is no array to save when save is called... Are you loading the Config before you try to save it?
  • hmm not sure in dbconfig i have
    return array (
     'db' => 
     array (
      'table' => 'config',
      'installed' => true,
      'autoload' => true,
      'autosave' => true,
     ),
    );
    

    package is on autoload and in a controller i used DbConfig::set('site.allow_reg','1'); nothing else
  • So you've never called config::load?
  • Hi nerdsrescueme, Any progress?
  • Haven't done it just yet, but I'm going to drop an issue on the account so I remember to do it next time I can.
  • hmm nope i was thinking that is autoload for
  • Lol, sorry. I currently have it configured to autoload on DbConfig::get... would anyone find it beneficial to autoload on a ::set call? The way I see it, most instances of creating config files can be done more easily by hand coding it... I am under the assumption that a configuration array would need to be read before it is written... Are there benefits to creating the config programatically that I'm not seeing? I'm open to suggestions...
  • Billmn on github fixed this issue... I used $part instead of $parts... dumb.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion