core/Mysql.php
public function update(string $tbname, array $values, $where = null, $args = null)
    {
        if (count($values) == 0) {
            return;
        }
        $where = trim($where);
        if (is_int($where) || is_numeric($where)) {
            $args = [intval($where)];
            $where = 'id=?';
        }
        $maps = [];
        $temp = [];
        foreach ($values as $key => $item) {
            if ($item === null) {
                $maps [] = '`' . $key . '`=NULL';
            } else if ($item instanceof SqlRaw) {
                $maps [] = '`' . $key . '`=' . $item->sql;
                if (is_array($item->args)) {
                    foreach ($item->args as $it) {
                        $temp[] = $it;
                    }
                }
            } else {
                $maps [] = '`' . $key . '`=?';
                $type = gettype($item);
                switch ($type) {
                    case 'bool':
                    case 'boolean':
                        $temp[] = $item ? 1 : 0;
                        break;
                    case 'int':
                    case 'integer':
                    case 'double':
                    case 'float':
                    case 'string':
                        $temp[] = $item;
                        break;
                        break;
                    case 'array':
                    case 'object':
                        $temp[] = json_encode($item, JSON_UNESCAPED_UNICODE);
                        break;
                    default :
                        $temp[] = strval($item);
                        break;
                }
            }
        }
        $sql = 'update ' . $tbname . ' set ' . join(',', $maps);
        if (!empty($where)) {
            $sql .= ' where ' . $where;
        }
        if (is_array($args)) {
            foreach ($args as $it) {
                $temp[] = $it;
            }
        } else {
            $temp[] = $args;
        }
        $Stm = $this->execute($sql, $temp);
        $Stm->closeCursor();
    }
public function update(string $tbname, array $values, $where = null, $args = null)
    {
        if (count($values) == 0) {
            return;
        }
        $where = trim($where);
        if (is_int($where) || is_numeric($where)) {
            $args = [intval($where)];
            $where = 'id=?';
        }
        $maps = [];
        $temp = [];
        foreach ($values as $key => $item) {
            if ($item === null) {
                $maps [] = '`' . $key . '`=NULL';
            } else if ($item instanceof SqlRaw) {
                $maps [] = '`' . $key . '`=' . $item->sql;
                if (is_array($item->args)) {
                    foreach ($item->args as $it) {
                        $temp[] = $it;
                    }
                }
            } else {
                $maps [] = '`' . $key . '`=?';
                $type = gettype($item);
                switch ($type) {
                    case 'bool':
                    case 'boolean':
                        $temp[] = $item ? 1 : 0;
                        break;
                    case 'int':
                    case 'integer':
                    case 'double':
                    case 'float':
                    case 'string':
                        $temp[] = $item;
                        break;
                        break;
                    case 'array':
                    case 'object':
                        $temp[] = json_encode($item, JSON_UNESCAPED_UNICODE);
                        break;
                    default :
                        $temp[] = strval($item);
                        break;
                }
            }
        }
        $sql = 'update ' . $tbname . ' set ' . join(',', $maps);
        if (!empty($where)) {
            $sql .= ' where ' . $where;
        }
        if (is_array($args)) {
            foreach ($args as $it) {
                $temp[] = $it;
            }
        } else {
            $temp[] = $args;
        }
        $Stm = $this->execute($sql, $temp);
        $Stm->closeCursor();
    }
更新记录集
@param string $tbname
@param array $values
@param null $where
@param null $args
@throws MysqlException