is it possible to declare constants in /application/config/constant.php from a DB table?
I’m trying to do something like this.
$result = $this->db->select( 'attr, value' )->from( 'app_conf')->where( 'city', 53 )->or_where( 'city', -1 )->order_by( 'city' )->get();
$app_conf = $result->result_array();
// var_dump( $app_conf );
foreach( $app_conf as $row )
{
define( "_{$row['attr']}", $row['value'] );
}
but right now I have to do it in every controller I create, so duplicating code and requiring to do changes all over if needed, which seems unnecessary!
Extend the CI Controller and place it in the application/core directory as MY_Controller. In the extended controller’s constructor place the above code. Now you can extend it from your controllers to execute the same code. So you are not required to write this code again and again.