Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Configuration on DB
  • Hi everyone,

    I need know how to save/initialize the table on database named config with all default config for my app.

    And too, how can save new configurations on DB and not into a config.php file?.

    Gracias
  • You use an extension.

    So instead of 

    $something = Config::get('something');

    you would use

    $something = Config::get('something.db');

    to fetch it from the database.

    To save data, it works the same, so

    Config::save('something.db', $something);

  • Thanks for answer Harro, But this dont work for me...
    I have this code:

        $title ='Mi empresa';
        Config::save('title.db',$title);
        $var = Config::get('title.db');

        var_dump($var);

    And the var_dump function return Null

    I need change anything on anyplace... i not understand the documentation
  • Did you create the 'config' table according to the documenation? 

    Is that table accessable via the default database definition? In other words, does this work?
    $result = \DB::select()->from('config')->execute();


  • I created the 'config' table.
    And yes, it is accessible through the default connection ...

    but this query

    $ result = \ DB :: select () -> from ('config') -> execute ();

    return this result

    Column not found: 1054 Unknown column 't0.id' in 'field list' with query: "SELECT` t0`identifier` AS` t0_c0`, `t0``id` AS` t0_c1` FROM` config` AS ` t0` "

    and I do not know why ...

    I can solved my first problem, y can create, edit and save the configuration on db.
    Now i need get all identifiers into an array or object for work with them.

    And the quoted query up, dont work, and i dont know method can be used for get this result without use pure sql queries.

  • and i need know how delete configurations.

            Config::delete("group.config");

    Dont work for me... -_-'
  • Harro VertonHarro Verton
    Accepted Answer
    That result is from an ORM query, a standard DB query generates "SELECT * FROM config". So you have to look at your code to see what goes wrong.

    Configuration is in memory, so a delete just deletes in memory. You need to save after a delete if you want the delete to be permanent.

    There is no method to load the entire config table into memory, Config is designed to load only what you need.

Howdy, Stranger!

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

In this Discussion