From c6395bc3bf61b91d885b4cc9142bb8da3f993d30 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 25 Feb 2015 10:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84map?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/think/model.php b/library/think/model.php index 243f7474..833b937c 100644 --- a/library/think/model.php +++ b/library/think/model.php @@ -19,7 +19,7 @@ class Model { // 当前数据库操作对象 protected $db = null; // 数据库对象池 - private $_db = []; + private $_db = []; // 主键名称 protected $pk = 'id'; // 数据表前缀 @@ -46,8 +46,6 @@ class Model { protected $scope = []; // 字段映射定义 protected $map = []; - // 是否自动检测数据表字段信息 - protected $autoCheckFields = false; /** * 架构函数 @@ -1302,11 +1300,16 @@ class Model { /** * 设置字段映射 * @access public - * @param array $map 映射 + * @param mixed $map 映射名称或者映射数据 + * @param string $name 映射的字段 * @return Model */ - public function map($map){ - $this->map = $map; + public function map($map,$name=''){ + if(is_array($map)){ + $this->map = array_merge($this->map,$map); + }else{ + $this->map[$map] = $name; + } return $this; } } \ No newline at end of file