db_mysqli::replace PHP Method

replace() public method

替换记录
public replace ( mixed $data, array $options = [] ) : false | integer
$data mixed 数据
$options array 参数表达式
return false | integer | integer
    public function replace($data, $options = array())
    {
        foreach ($data as $key => $val) {
            $value = $this->parseValue($val);
            if (is_scalar($value)) {
                // 过滤非标量数据
                $values[] = $value;
                $fields[] = $this->parseKey($key);
            }
        }
        $sql = 'REPLACE INTO ' . $this->parseTable($options['table']) . ' (' . implode(',', $fields) . ') VALUES (' . implode(',', $values) . ')';
        return $this->execute($sql);
    }