core/Mysql.php
public function insert(string $tbname, array $values = [])
    {
        if (count($values) == 0) {
            return;
        }
        $names = [];
        $vals = [];
        $temp = [];
        foreach ($values as $key => $item) {
            $names[] = '`' . $key . '`';
            if ($item === null) {
                $vals [] = 'NULL';
            } else if ($item instanceof SqlRaw) {
                $vals [] = $item->sql;
                if (is_array($item->args)) {
                    foreach ($item->args as $it) {
                        $temp[] = $it;
                    }
                }
            } else {
                $vals [] = '?';
                $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 = 'insert into ' . $tbname . '(' . join(',', $names) . ') values (' . join(',', $vals) . ')';
        $Stm = $this->execute($sql, $temp);
        $Stm->closeCursor();
    }
public function insert(string $tbname, array $values = [])
    {
        if (count($values) == 0) {
            return;
        }
        $names = [];
        $vals = [];
        $temp = [];
        foreach ($values as $key => $item) {
            $names[] = '`' . $key . '`';
            if ($item === null) {
                $vals [] = 'NULL';
            } else if ($item instanceof SqlRaw) {
                $vals [] = $item->sql;
                if (is_array($item->args)) {
                    foreach ($item->args as $it) {
                        $temp[] = $it;
                    }
                }
            } else {
                $vals [] = '?';
                $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 = 'insert into ' . $tbname . '(' . join(',', $names) . ') values (' . join(',', $vals) . ')';
        $Stm = $this->execute($sql, $temp);
        $Stm->closeCursor();
    }
插入记录
@param string $tbname
@param array $values
@throws MysqlException