public function __construct() { if (!isset($this->db_config[$this->db_setting])) { $this->db_setting = 'default'; } //$this->table_name = $this->table_name; $this->db = db_factory::get_instance($this->db_config)->get_database($this->db_setting); }
function __construct() { //$this->update_log_db = bpBase::loadModel('update_log_model'); parent::__construct(); $checkAccess = $this->exitWithoutAccess('system', 'manage'); $this->dbConfig = array('default' => array('hostname' => DB_HOSTNAME, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'tablepre' => TABLE_PREFIX, 'charset' => DB_CHARSET, 'type' => 'mysql', 'debug' => DEBUG, 'pconnect' => 0, 'autoconnect' => 0)); bpBase::loadSysClass('db_factory'); $this->db = db_factory::get_instance($this->dbConfig)->get_database('default'); }
public function __construct($db_config = '', $table_name = '') { //4.13 增加M函数功能, $this->db_config = $db_config ? $db_config : $this->db_config; //4.13 $this->table_name = $table_name ? $table_name : $this->table_name; //4.13 if (!isset($this->db_config[$this->db_setting])) { $this->db_setting = 'default'; } $this->table_name = $this->db_config[$this->db_setting]['tablepre'] . $this->table_name; $this->db_tablepre = $this->db_config[$this->db_setting]['tablepre']; $this->db = db_factory::get_instance($this->db_config)->get_database($this->db_setting); }
public static function testdb($dbtype, $dbhost, $dbuser, $dbpw, $dbname) { global $con; $db_conf = array(); $db_conf['import_array'] = array(); $db_conf['import_array']['type'] = $dbtype; $db_conf['import_array']['hostname'] = $dbhost; $db_conf['import_array']['username'] = $dbuser; $db_conf['import_array']['password'] = $dbpw; $db_conf['import_array']['database'] = $dbname; //$db_conf['import_array']['charset']= $import_info[dbcharset]; //返回一个当前配置所需要的数据库连接 pc_base::load_sys_class('db_factory'); $thisdb = db_factory::get_instance($db_conf)->get_database('import_array'); $link = $thisdb->connect(); if ($link) { return 'OK'; } else { return 'false'; } }
/** * 数据库修复、优化 */ public function public_repair() { $database = pc_base::load_config('database'); $tables = $_POST['tables'] ? $_POST['tables'] : trim($_GET['tables']); $operation = trim($_GET['operation']); $pdo_name = trim($_GET['pdo_name']); $this->db = db_factory::get_instance($database)->get_database($pdo_name); $tables = is_array($tables) ? implode(',', $tables) : $tables; if ($tables && in_array($operation, array('repair', 'optimize'))) { $this->db->query("{$operation} TABLE {$tables}"); showmessage(L('operation_success'), '?m=admin&c=database&a=export&pdoname=' . $pdo_name); } elseif ($tables && $operation == 'showcreat') { $this->db->query("SHOW CREATE TABLE {$tables}"); $structure = $this->db->fetch_next(); $structure = $structure['Create Table']; $show_header = true; include $this->admin_tpl('database_structure'); } else { showmessage(L('select_tbl'), '?m=admin&c=database&a=export&pdoname=' . $pdo_name); } }
define('IN_WX', true); define('WX_PATH', substr(dirname(__FILE__), 0, -8) . DIRECTORY_SEPARATOR); //网站真实路径 define('SITE_URL', 'http://www.cathassist.org/'); //站点访问路径 define('ERRORLOG', false); define('GZIP', true); ERRORLOG ? set_error_handler('my_error_handler') : error_reporting(E_ERROR | E_WARNING | E_PARSE); //设置本地时差 function_exists('date_default_timezone_set') && date_default_timezone_set('Etc/GMT-8'); define('CHARSET', 'utf-8'); //输出页面字符集 header('Content-type: text/html; charset=' . CHARSET); if (GZIP && function_exists('ob_gzhandler')) { ob_start('ob_gzhandler'); } else { ob_start(); } require WX_PATH . 'include' . DIRECTORY_SEPARATOR . 'define.php'; require WX_PATH . 'include' . DIRECTORY_SEPARATOR . 'global.func.php'; //加载公共方法 require WX_PATH . 'include' . DIRECTORY_SEPARATOR . 'db_factory.class.php'; //加载数据库工厂类 //实现化数据库类 $db = db_factory::get_instance()->get_database('default'); if (!get_magic_quotes_gpc()) { $_POST = new_addslashes($_POST); $_GET = new_addslashes($_GET); $_REQUEST = new_addslashes($_REQUEST); $_COOKIE = new_addslashes($_COOKIE); }
private function init_cmsware_db() { pc_base::load_sys_class('db_factory', '', 0); $this->cmsware_db_config = pc_base::load_config('database'); $this->cmsware_db_setting = 'default'; $this->cmsware_db = db_factory::get_instance($this->cmsware_db_config)->get_database($this->cmsware_db_setting); $this->cmsware_db_tablepre = $this->cmsware_db_config[$this->cmsware_db_setting]['tablepre']; $this->obj_category = pc_base::load_model('category_model'); $this->obj_model = pc_base::load_model('sitemodel_model'); }