使用 $_POST 参数创建 table

creating a table using $_POST parameters

我正在尝试创建一个 table,其中 table 名称是一个参数。可能吗?像这样:

$result = pg_query("CREATE TABLE '$_POST[nome_arquivo_software]' (
    id serial CONSTRAINT pk_'$_POST[nome_arquivo_software]' PRIMARY KEY,
    nome  varchar (80),
    email varchar (80),
    estado varchar (80),
    acessos numeric
)"); 

table 名称不是字符串文字,而是 identifier -> 将 single-quote 更改为 double-quotes -> 带引号的标识符。

id 字段的名称不是 pk_+string 字面值,但整个是一个标识符 -> "pk_...."

// <--- intensive checks on $_POST[nome_arquivo_software] and $_POST[nome_arquivo_software] here
$result = pg_query("
    CREATE TABLE \"$_POST[nome_arquivo_software]\" (
    id serial CONSTRAINT \"pk_$_POST[nome_arquivo_software]\" PRIMARY KEY,
    nome  varchar (80),
    email varchar (80),
    estado varchar (80),
    acessos numeric
    )
");