优化子站点配置

master
chenzhi 4 years ago
parent f034698dbc
commit 753098a85f

@ -1061,8 +1061,16 @@ function showNumPercent($num)
function SM($name='', $tablePrefix='tab_') function SM($name='', $tablePrefix='tab_')
{ {
$tableName = strtolower($tablePrefix.$name); $tableName = strtolower($tablePrefix.$name);
if(in_array($tableName,C('SUBSITE_TABLE')) && IS_SUBSITE){ if(is_subsiteTable($tableName)){
return M($name, $tablePrefix,SUBSITE_DB); return M($name, $tablePrefix,SUBSITE_DB);
} }
return M($name, $tablePrefix); return M($name, $tablePrefix);
} }
//判断是否有子站点表格
function is_subsiteTable($tableName)
{
if(in_array($tableName,C('SUBSITE_TABLE')) && IS_SUBSITE){
return true;
}
return false;
}

@ -34,12 +34,12 @@ class SpendModel extends Model
array('order_number', '', self::MODEL_INSERT), array('order_number', '', self::MODEL_INSERT),
); );
protected function _after_select(&$result, $options) // protected function _after_select(&$result, $options)
{ // {
foreach ($result as $key => $value) { // foreach ($result as $key => $value) {
// $result[$key]['pay_way'] = date('Y-m-d ', $value['time']); // // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']);
} // }
} // }
/** /**
* 构造函数 * 构造函数
@ -51,6 +51,11 @@ class SpendModel extends Model
{ {
/* 设置默认的表前缀 */ /* 设置默认的表前缀 */
$this->tablePrefix = 'tab_'; $this->tablePrefix = 'tab_';
if(is_subsiteTable("tab_spend")){
//修改连接
$this->connection = SUBSITE_DB;
$connection = SUBSITE_DB;
}
/* 执行构造方法 */ /* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection); parent::__construct($name, $tablePrefix, $connection);
} }
@ -796,12 +801,12 @@ class SpendModel extends Model
} else { } else {
$row = 10; $row = 10;
} }
$list = $this->db(1) $list = $this
->where($map) ->where($map)
->page($page, $row) ->page($page, $row)
->order($order ? $order : 'pay_time desc') ->order($order ? $order : 'pay_time desc')
->select(); ->select();
$count = $this->db(1)->where($map)->count(); $count = $this->where($map)->count();
$data['data'] = $list; $data['data'] = $list;
$page = set_pagination($count, $row); $page = set_pagination($count, $row);
if ($page) { if ($page) {

@ -35,6 +35,13 @@ if(!is_file(APP_PATH . 'User/Conf/config.php')){
*/ */
define ( 'RUNTIME_PATH', './Runtime/' ); define ( 'RUNTIME_PATH', './Runtime/' );
/**
* 项目配置
*/
define ( 'IS_SUBSITE', false);
define ( 'SUBSITE_NAME', "all");
define ( 'SUBSITE_INDEX', "admin.php" );//子站点路口影响session
/** /**
* 引入核心入口 * 引入核心入口
* ThinkPHP亦可移动到WEB以外的目录 * ThinkPHP亦可移动到WEB以外的目录

@ -35,8 +35,8 @@ define ( 'RUNTIME_PATH', './Runtime/' );
* 项目配置 * 项目配置
*/ */
$JBC_DB_CONFIG = include_once APP_PATH."/Common/Conf/env.php"; $JBC_DB_CONFIG = include_once APP_PATH."/Common/Conf/env.php";
$JBC_DB_CONFIG = $JBC_DB_CONFIG['JBC_DB_CONFIG']; $JBC_DB_CONFIG = $JBC_DB_CONFIG['SUBSITE_DB_CONFIG']['JBC_DB_CONFIG'];
define ( 'IS_SUBSITE', TRUE); define ( 'IS_SUBSITE', true);
define ( 'SUBSITE_NAME', "jbc"); define ( 'SUBSITE_NAME', "jbc");
define ( 'SUBSITE_DB', $JBC_DB_CONFIG ); define ( 'SUBSITE_DB', $JBC_DB_CONFIG );
define ( 'SUBSITE_INDEX', "jbc.php" );//子站点路口影响session define ( 'SUBSITE_INDEX', "jbc.php" );//子站点路口影响session

Loading…
Cancel
Save