• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Database Driven Config Question

#1
I am working on a config file that I get my contents from database and set them in my config

application/config/setting.php

As you can see below I can require the database file fine,

Is there any way to be able to require codeigniter URI segments

Because currently I have to get segments like this  so would be better if I could use the url in my config file any ideas how to load url helper in my config file below 

cheers.


PHP Code:
$segments explode('/'trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments count($segments); 
$currentSegment 
$segments[$numSegments 3]; 

PHP Code:
<?php

$config 
= array();

require_once(
BASEPATH 'database/DB.php');

$db =& DB();

$db->where('type''config');
$query $db->get($db->dbprefix 'setting');

foreach (
$query->result_array() as $result) {
    
$config[$result['item']] = $result['value'];
}

$segments explode('/'trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments count($segments); 
$currentSegment $segments[$numSegments 3];

if (
$currentSegment == 'admin') {
    
$db->where('code'config_item('admin_language'));
} elseif (
$currentSegment != 'admin') {
    
$db->where('code'config_item('language'));
}

$lang_query $db->get($db->dbprefix 'language');

if (
$query->num_rows() > 0) {
    
$config['language']    = strtolower($lang_query->row()->name);
} else {
    
$config['language']    = 'english';

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Database Driven Config Question - by wolfgang1983 - 08-17-2017, 03:56 AM
RE: Database Driven Config Question - by salain - 08-17-2017, 04:42 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.