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

博客介绍了CI框架动态路由相关内容,可从数据库读取路由配置,涉及的配置文件有/config/routes.php和/config/database_route.php。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值