From 753098a85f46aaf7200781ac2ffc3cff8d8bfddf Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 14 Dec 2020 10:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 10 +++++++++- Application/Admin/Model/SpendModel.class.php | 21 ++++++++++++-------- admin.php | 7 +++++++ jbc.php | 4 ++-- 4 files changed, 31 insertions(+), 11 deletions(-) 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