标签:
起因:
1 <?php 2 include(BASEPATH.‘core/Common.php‘); 3 include(BASEPATH.‘database/DB.php‘); 4 5 class Activedb 6 { 7 var $db_config = array( 8 ‘dsn‘ => ‘‘, 9 ‘hostname‘ => ‘localhost‘, 10 ‘username‘ => ‘root‘, 11 ‘password‘ => ‘‘, 12 ‘database‘ => ‘‘, 13 ‘dbdriver‘ => ‘mysqli‘, 14 ‘dbprefix‘ => ‘‘, 15 ‘pconnect‘ => FALSE, 16 ‘db_debug‘ => TRUE, 17 ‘cache_on‘ => FALSE, 18 ‘cachedir‘ => ‘‘, 19 ‘char_set‘ => ‘utf8‘, 20 ‘dbcollat‘ => ‘utf8_general_ci‘, 21 ‘swap_pre‘ => ‘‘, 22 ‘encrypt‘ => FALSE, 23 ‘compress‘ => FALSE, 24 ‘stricton‘ => FALSE, 25 ‘failover‘ => array(), 26 ‘save_queries‘ => TRUE 27 ); 28 public function db_link(){ 29 $db = & DB($this->db_config); 30 return $db; 31 } 32 }
<?php define(‘BASEPATH‘, __DIR__ . ‘/activeDB/‘); define(‘APPPATH‘, __DIR__ . ‘/activeDB/‘); require_once BASEPATH . ‘config/database.php‘; require_once(BASEPATH.‘models/Comm_model.php‘); class Test{ var $db; var $Comm_model; function __construct(){ //链接数据库 $activedb = new Activedb(); $this->db = & $activedb->db_link(); //实例化通用模型 $Comm_model = new Comm_model($this->db); $this->Comm_model = $Comm_model; } }
标签:
原文地址:http://www.cnblogs.com/martin-tan/p/4800892.html