0
echo $_POST['IDnum'];
$result = pg_prepare($conn, "city_delete",
    "DELETE FROM lab5.city WHERE lab5.city.id = $1");
$result = pg_execute($conn, "city_delete", array($_POST['IDnum']));

这将显示要删除的行的正确 ID 号,并将在 PSQL 中将其删除,但在 PHP 中实现时不会删除?有任何想法吗?

4

1 回答 1

1

尝试这个:

$result = pg_prepare($conn, "city_delete",
'DELETE FROM lab5.city WHERE lab5.city.id = $1');

您使用的双引号使 $1 成为 PHP 变量而不是字符串。

在此处查看 pg_prepare 的示例:http: //php.net/manual/en/function.pg-prepare.php

于 2013-03-05T19:21:12.777 回答