diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 085401c84..7719c610f 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1061,8 +1061,16 @@ function showNumPercent($num) function SM($name='', $tablePrefix='tab_') { $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); } +//判断是否有子站点表格 +function is_subsiteTable($tableName) +{ + if(in_array($tableName,C('SUBSITE_TABLE')) && IS_SUBSITE){ + return true; + } + return false; +} diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 40204893b..dffcf99d7 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -34,12 +34,12 @@ class SpendModel extends Model array('order_number', '', self::MODEL_INSERT), ); - protected function _after_select(&$result, $options) - { - foreach ($result as $key => $value) { - // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']); - } - } + // protected function _after_select(&$result, $options) + // { + // foreach ($result as $key => $value) { + // // $result[$key]['pay_way'] = date('Y-m-d ', $value['time']); + // } + // } /** * 构造函数 @@ -51,6 +51,11 @@ class SpendModel extends Model { /* 设置默认的表前缀 */ $this->tablePrefix = 'tab_'; + if(is_subsiteTable("tab_spend")){ + //修改连接 + $this->connection = SUBSITE_DB; + $connection = SUBSITE_DB; + } /* 执行构造方法 */ parent::__construct($name, $tablePrefix, $connection); } @@ -796,12 +801,12 @@ class SpendModel extends Model } else { $row = 10; } - $list = $this->db(1) + $list = $this ->where($map) ->page($page, $row) ->order($order ? $order : 'pay_time desc') ->select(); - $count = $this->db(1)->where($map)->count(); + $count = $this->where($map)->count(); $data['data'] = $list; $page = set_pagination($count, $row); if ($page) { diff --git a/admin.php b/admin.php index 3093bc696..c607fbea6 100644 --- a/admin.php +++ b/admin.php @@ -35,6 +35,13 @@ if(!is_file(APP_PATH . 'User/Conf/config.php')){ */ define ( 'RUNTIME_PATH', './Runtime/' ); +/** + * 项目配置 + */ +define ( 'IS_SUBSITE', false); +define ( 'SUBSITE_NAME', "all"); +define ( 'SUBSITE_INDEX', "admin.php" );//子站点路口,影响session + /** * 引入核心入口 * ThinkPHP亦可移动到WEB以外的目录 diff --git a/jbc.php b/jbc.php index f4f81d45b..77a428be7 100644 --- a/jbc.php +++ b/jbc.php @@ -35,8 +35,8 @@ define ( 'RUNTIME_PATH', './Runtime/' ); * 项目配置 */ $JBC_DB_CONFIG = include_once APP_PATH."/Common/Conf/env.php"; -$JBC_DB_CONFIG = $JBC_DB_CONFIG['JBC_DB_CONFIG']; -define ( 'IS_SUBSITE', TRUE); +$JBC_DB_CONFIG = $JBC_DB_CONFIG['SUBSITE_DB_CONFIG']['JBC_DB_CONFIG']; +define ( 'IS_SUBSITE', true); define ( 'SUBSITE_NAME', "jbc"); define ( 'SUBSITE_DB', $JBC_DB_CONFIG ); define ( 'SUBSITE_INDEX', "jbc.php" );//子站点路口,影响session