编译插入数据
@param array $data 数组
@return array
431665
protected function compileInsertAllData()
    {
        $placeholders = array_pad([], count($this->insertFields), '?');
        $this->arguments = [];
        foreach ($this->insertValues as $key => $row) {
            $this->arguments = ArrayLib::array_add($this->arguments, $row);
            $this->insertFragment[] = '('.implode(', ', $placeholders).')';
        }
        $inserFields = [];
        foreach ($this->insertFields as $key => $row) {
            $insertKey = "`{$key}`";
            $inserFields[$insertKey] = $row;
        }
        $this->insertString = 'INSERT INTO ' . $this->getFrom() . ' (' . implode(', ', $inserFields) . ') VALUES '.implode(', ', $this->insertFragment);
    }
784066
protected function decodeData(array $data)
    {
        $result = [];

        if (is_array($data[0])) {
            foreach ($data[0] as $k => $v) {
                $result[$k] = $this->decodeData([$data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]]);
            }

            return $result;
        }

        return [
            'name' => $data[0],
            'type' => $data[1],
            'tmp_name' => $data[2],
            'error' => $data[3],
            'size' => $data[4],
        ];
    }
456328
public function data($data = []) {
        if (count($data) == 0) {
            return $this->_data;
        }
        else {
            $this->_data = $data;
        }

        return null;
    }
303380
protected function parseSet($data) {
        foreach ($data as $key=>$val){
            if(is_array($val) && 'exp' == $val[0]){
                $set[]  =   $this->parseKey($key).'='.$val[1];
            }elseif(is_null($val)){
                $set[]  =   $this->parseKey($key).'=NULL';
            }elseif(is_scalar($val)) {// 过滤非标量数据
                if(0===strpos($val,':') && in_array($val,array_keys($this->bind)) ){
                    $set[]  =   $this->parseKey($key).'='.$this->escapeString($val);
                }else{
                    $name   =   count($this->bind);
                    $set[]  =   $this->parseKey($key).'=:'.$name;
                    $this->bindParam($name,$val);
                }
            }
        }
        return ' SET '.implode(',',$set);
    }
96033
public function parse($data)
    {
        if ($data === null || !is_string($data)) {
            return array();
        }

        if (substr($data, 0, 1) !== '{' &&
            substr($data, 0, 1) !== '[') {
            return array();
        }

        return (array) json_decode($data, true);
    }
1336973
public function data($data=''){
        if('' === $data && !empty($this->data)) {
            return $this->data;
        }
        if(is_object($data)){
            $data   =   get_object_vars($data);
        }elseif(is_string($data)){
            parse_str($data,$data);
        }elseif(!is_array($data)){
            E(L('_DATA_TYPE_INVALID_'));
        }
        $this->data = $data;
        return $this;
    }
54841
private function hydrateIfJsonToArray($data)
    {
        if (is_array($data)) {
            return $data;
        }
        elseif (is_string($data)) {
            $attempt = json_decode($data, true);
            return empty($attempt) ? $data : $attempt;
        }

        return [];
    }
1134037
public function unserialize($data)
    {
        $data = unserialize($data);

        $this->setData($data);

        return $this->getData();
    }
1251789
public function json(array $data)
    {
        $data = json_encode($data);
        $response = $this->withHeader('Content-Type', 'application/json');
        $response->getBody()->write($data);

        return $response;
    }
91126
protected function _toArray($data)
    {
        $array = array();

        foreach ($data as $key => $value) {
            if (is($value, 'AnDomainBehaviorSerializable')) {
                $array[$key] = $value->toSerializableArray();
            } elseif (is_array($value)) {
                $array[$key] = $this->_toArray($value);
            } else {
                $array[$key] = $value;
            }
        }

        return $array;
    }
990114
public function create($data='') {
        // 如果没有传值默认取POST数据
        if(empty($data)) {
            $data   =   I('post.');
        }elseif(is_object($data)){
            $data   =   get_object_vars($data);
        }
        // 验证数据
        if(empty($data) || !is_array($data)) {
            $this->error = L('_DATA_TYPE_INVALID_');
            return false;
        }

        // 检测提交字段的合法性
        if(isset($this->options['field'])) { // $this->field('field1,field2...')->create()
            $fields =   $this->options['field'];
            unset($this->options['field']);
        }
        if(isset($fields)) {
            if(is_string($fields)) {
                $fields =   explode(',',$fields);
            }
        }

        // 验证完成生成数据对象
        if($this->autoCheckFields) { // 开启字段检测 则过滤非法字段数据
            $fields =   $this->getDbFields();
            foreach ($data as $key=>$val){
                if(!in_array($key,$fields)) {
                    unset($data[$key]);
                }elseif(MAGIC_QUOTES_GPC && is_string($val)){
                    $data[$key] =   stripslashes($val);
                }
            }
        }

        // 赋值当前数据对象
        $this->data =   $data;
        // 返回创建的数据以供其他调用
        return $data;
     }
42813
protected function filter(array $data): array
    {
        return array_filter($data, function ($item) {
            if (is_array($item)) {
                return $this->filter($item);
            }
            $item = trim($item);
            //防止字符串'0'
            return is_numeric($item) || !empty($item);
        });
    }
31392
public function validate( array $data ) {

		$errors = [];

		foreach( $this->fields as $field ) {

			$f = $field->name;
			$v = isset($data[$f]) ? $data[$f] : null;

			list($clean, $errors[$f]) = $field->validate($v);

			if( !$errors[$f] )
				$data[$f] = $clean;

		}

		return [
			$data,
			array_filter($errors),
		];

	}
276179
protected function formatData(array $data)
    {
        $formatted = [];

        foreach ($data as $key => $value) {
            if (is_array($value)) {
                if (isset($value['value'])) {
                    $formatted[$key] = $value;

                    continue;
                }

                if (count($value) >= 2) {
                    $value = [
                        'value' => $value[0],
                        'color' => $value[1],
                    ];
                }
            } else {
                $value = [
                    'value' => strval($value),
                ];
            }

            $formatted[$key] = $value;
        }

        return $formatted;
    }
845606
private static function separate(array $data)
    {
        $array = [];

        foreach ($data as $provider) {

            if(($bool = self::isDelim($provider)) === false) {
                $array['required'][] = $provider;
            }
            else {
                if ($bool[1] === 'true') {
                    $array['required'][] = strval($bool[0]);
                } else {
                    $array['hidden'][] = strval($bool[0]);
                }
            }
        }

        return $array;

    }
270433
public function getData($data)
    {
        if ($this->hasData($data)) {
            return $this->getAttribute(sprintf('data-%s', $data));
        } else {
            return false;
        }
    }
997538
public function login($data)
    {
        // 1. 校验用户账号密码是否符合规则
        $validator = wei()->validate([
            'data' => $data,
            'rules' => [
                'username' => [
                    'required' => true,
                ],
                'password' => [
                    'required' => true,
                ],
            ],
            'names' => [
                'username' => '帐号',
                'password' => '密码',
            ],
        ]);

        if (!$validator->isValid()) {
            return ['code' => -1, 'message' => $validator->getFirstMessage()];
        }

        // 2. 检查手机/邮箱/用户名是否存在
        $user = wei()->user();
        switch (true) {
            case wei()->isMobileCn($data['username']):
                $field = 'mobile';
                $user->mobileVerified();
                break;

            case wei()->isEmail($data['username']):
                $field = 'email';
                break;

            default:
                $field = 'username';
        }

        /** @var User $user */
        $user = $user->find([$field => $data['username']]);
        if (!$user) {
            return ['code' => -2, 'message' => '用户名不存在或密码错误'];
        }

        // 3. 检查用户是否有效
        if (!$user['enable']) {
            return ['code' => -3, 'message' => '用户未启用,无法登录'];
        }

        // 4. 验证密码是否正确
        if (!$user->verifyPassword($data['password'])) {
            return ['code' => -4, 'message' => '用户不存在或密码错误'];
        }

        // 5. 验证通过,登录用户
        return $this->loginByRecord($user);
    }