Dynamic Constants in Codeigniter 2.1.2
I wanted to define the settings as constants to be able to control them through a settings page.
Created a table in the DB to hold the constant name and value
in /application/config/constants.php I added this:
require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get( 'settings' );
foreach( $query->result() as $row ){ define($row->title, $row->value); }
Written by Diego...
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#