create()方法的源码如下(具体文件位置我暂时找不到 囧rz,是在这篇东西里搜到的):
/** * 创建数据对象 但不保存到数据库 * @access public * @param mixed $data 创建数据 * @param string $type 状态 * @return mixed */ public function create($data='',$type='') { // 如果没有传值默认取POST数据 if(empty($data)) { $data = $_POST; }elseif(is_object($data)){ $data = get_object_vars($data); } // 验证数据 if(empty($data) || !is_array($data)) { $this->error = L('_DATA_TYPE_INVALID_'); return false; } // 检查字段映射 $data = $this->parseFieldsMap($data,0); // 状态 $type = $type?$type:(!empty($data[$this->getPk()])?self::MODEL_UPDATE:self::MODEL_INSERT); // 检测提交字段的合法性 if(isset($this->options['field'])) { // $this->field('field1,field2...')->create() $fields = $this->options['field']; unset($this->options['field']); }elseif($type == self::MODEL_INSERT && isset($this->insertFields)) { $fields = $this->insertFields; }elseif($type == self::MODEL_UPDATE && isset($this->updateFields)) { $fields = $this->updateFields; } if(isset($fields)) { if(is_string($fields)) { $fields = explode(',