ci框架动态路由读取数据库获取路由配置

ci框架动态路由读取数据库获取路由配置

/config/routes.php



这里可以直接读取数据库
$CFG =& load_class('Config', 'core');
$CFG->load('database_route');
$database_route		= $CFG->item('database_route');
$query_builder		= NULL;

require_once(BASEPATH.'database/DB.php');
$db		=& DB($database_route, $query_builder);
$result = $db->get_where("dede_arctype")->result_array();
print_r($result);
echo 3;exit;


$route['default_controller']	= 'welcome';
$route['404_override']			= 'four404';

/config/database_route.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$config['database_route'] = array(
    'dsn'	=> '',
    'hostname' => '127.0.0.1',
    'username' => 'a',
    'password' => 'vb',
    'database' => 'c',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

 


版权声明:本文为lumengabc原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。