Welcome Guest, Not a member yet? Register   Sign In
Load custom settings from database in all pages
#3

[eluser]CroNiX[/eluser]
An example of a library, which you would want to autoload to be available everywhere:

/application/libraries/site_config.php
Code:
class Site_config {
  public function __construct()
  {
    //get CI instance
    $CI =& get_instance();

    //This would normally be a model, but just to show...

    //Create new CI "site_config" property and assign data from db to it
    $CI->site_config = $CI->db->select('id, name, value')->get('your_table')->result_array();
  }
}

Now in all of your other controllers, models, etc, $this->site_config will contain the array of data from the db


Messages In This Thread
Load custom settings from database in all pages - by El Forum - 08-10-2014, 07:03 AM
Load custom settings from database in all pages - by El Forum - 08-10-2014, 07:26 AM
Load custom settings from database in all pages - by El Forum - 08-10-2014, 09:47 AM
Load custom settings from database in all pages - by El Forum - 08-10-2014, 10:57 AM
Load custom settings from database in all pages - by El Forum - 08-10-2014, 11:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB