插入一条新的记录到表
@param $data array 必须是键值（表的字段对应值）对应
@return int
421888
public function put($data)
    {
        if (empty($data) or !is_array($data))
        {
            return false;
        }
        if ($this->db->insert($data, $this->table))
        {
            $lastInsertId = $this->db->lastInsertId();
            if ($lastInsertId == 0)
            {
                return true;
            }
            else
            {
                return $lastInsertId;
            }
        }
        else
        {
            return false;
        }
    }
526025
public static function determine($data) : int
    {
        switch (gettype($data)) {
            case 'string':
                return self::CATEGORICAL;

            case 'double':
                return self::CONTINUOUS;

            case 'integer':
                return self::CONTINUOUS;

            case 'resource':
                return self::RESOURCE;

            default:
                return self::OTHER;
        }
    }
895316
public function replaceGetId($data) {
        $pri = $this->connection->getPrimaryKey();
        #主键为空或0时删除主键
        if (isset($data[$pri]) && empty($data[$pri])) {
            unset($data[$pri]);
        }
        return $this->insertGetId($data, 'replace');
    }
286933
public function updates($data)
    {
        $data = &$this->loadFilterData($data);
        if ( $data == false ) {
            return false;
        }
        $conditions = $this->sqlBuilder->buildCondition();
        return $this->db->update($this->table, $data, $conditions);
    }
505333
public function insert($data)
    {
        $db = $this->load();
        $db[] = $data;
        return $this->rewrite($db);
    }
807240
public static function update($data)
    {
        $self      = self::getInstance();

        $table     = $self->table_name;
        $param     = $self->makeUpdateParameter($data);
        $value     = $self->makeInsertParameter($data);

        $statement = "UPDATE {$table} SET {$param} ";
        $execute   = $self->exec($statement, $value);

        return $execute;
    }
587012
protected function addByUser(array $data)
    {
        $result = null;
        $this->hook->attach('rating.add.user.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        if (empty($data['rating'])) {
            return 0; // Do not add rating 0 (unvote)
        }

        $result = $this->db->insert('rating_user', $data);
        $this->hook->attach('rating.add.user.after', $data, $result, $this);
        return (int) $result;
    }
855379
public function update(array $data = [])
    {
        $options = $this->parseExpress();
        $data    = array_merge($options['data'], $data);
        $pk      = $this->getPk($options);
        $where   = [];
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }

        if (empty($options['where'])) {
            // 如果存在主键数据 则自动作为更新条件
            if (is_string($pk) && isset($data[$pk])) {
                $where[$pk] = $data[$pk];
                if (!isset($key)) {
                    $key = 'think:' . $options['table'] . '|' . $data[$pk];
                }
                unset($data[$pk]);
            } elseif (is_array($pk)) {
                // 增加复合主键支持
                foreach ($pk as $field) {
                    if (isset($data[$field])) {
                        $where[$field] = $data[$field];
                    } else {
                        // 如果缺少复合主键数据则不执行
                        throw new Exception('miss complex primary data');
                    }
                    unset($data[$field]);
                }
            }
            if (!isset($where)) {
                // 如果没有任何更新条件则不执行
                throw new Exception('miss update condition');
            } else {
                $options['where']['AND'] = $where;
            }
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['AND'][$pk])) {
            $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind);
        }

        //过滤无效字段
        $this->filter($data);

        // 生成UPDATE SQL语句
        $sql = $this->builder->update($data, $options);
        // 获取参数绑定
        $bind = $this->getBind();
        if ($options['fetch_sql']) {
            // 获取实际执行的SQL语句
            return $this->connection->getRealSql($sql, $bind);
        } else {
            // 执行操作
            $result = '' == $sql ? 0 : $this->execute($sql, $bind);
            if ($result) {
                if (is_string($pk) && isset($where[$pk])) {
                    $data[$pk] = $where[$pk];
                } elseif (is_string($pk) && isset($key) && strpos($key, '|')) {
                    list($a, $val) = explode('|', $key);
                    unset($a);
                    $data[$pk]     = $val;
                }
                $options['data'] = $data;
                $this->trigger('after_update', $options);
            }
            return $result;
        }
    }
1144698
public function update($data)
  {
    $this->stmt['action'] = 'UPDATE';
    $this->stmt['cols'] = array_merge($this->stmt['cols'], $data);
    return $this;
  }
310589
public function update(array $data = [])
    {
        $this->parseOptions();

        $this->options['data'] = array_merge($this->options['data'], $data);

        return $this->connection->update($this);
    }
46766
public function update($data)
    {
        $validator = new StringValidator();
        $validator->max = 255;

        foreach ($data as $key => $value) {
            if (!in_array($key, $this->readonly) && array_key_exists($key, $this->settings)) {
                if (!$validator->validate($value)) {
                    return false;
                }
                if (!$this->config->set($key, $value)) {
                    return false;
                }
            }
        }
        return true;
    }
971851
public function updateIndexOne(array $data)
    {
        if (!is_array($data)) {
            throw new \Exception('你的索引参数不是一个数组');
        }

        if (count($data) == count($data, 1)) {
            // 一维数组
            $this->getIndex()->update(new \XSDocument($data));
        }

        //索引是否立即生效
        if ($this->flush_index) {
            $this->getIndex()->flushIndex();
        }

        return $this->getIndex();
    }
310345
public function update(array $data)
    {
        $this->attributes = new Collection(array_merge($this->attributes->toArray(), $data));

        return $this->save();
    }
108174
public function row(array $data): int
    {
        array_push($this->rows, $data);
        $pdoStatement = $this->provideStatement();
        $this->execute($pdoStatement);
        return $this->getLastInsertId();
    }
630841
public function update($data = [], $wheres = [])
    {
        if (is_array($wheres) && count($wheres) > 0) {
            foreach ($wheres as $column => $column_value) {
                if (is_array($column_value)) {
                    $this->db->where($column, $column_value, self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($column, $column_value, self::OPERATOR_EQUAL_TO);
                }
            }
        }
        if ($this->db->update($this->table, $data)) {
            return (int) $this->db->count;
        }

        return 0;
    }
172305
public function write(string $data): int
    {
        $length = fputs($this->resource, $data, strlen($data));
        if (false === $length) {
            if (stream_get_meta_data($this->resource)['timed_out']) {
                throw new Timeout(
                        'Writing of ' . strlen($data) . ' bytes failed:'
                        . ' timeout of ' . $this->timeout . ' seconds exceeded'
                );
            }

            throw new ConnectionFailure(
                    'Writing of ' . strlen($data) . ' bytes failed.'
            );
        }

        return $length;
    }
525076
public function copyFrom($data)
    {
        if (is_array($data) || $data instanceof \Traversable) {
            if ($this->getCount() > 0) {
                $this->clear();
            }
            if ($data instanceof CMap) {
                $data = $data->_data;
            }
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        } elseif ($data !== null) {
            throw new Exception('实例化列表参数必须是数组或可遍历的对象', 100100601);
        }
    }