您不能使用 pg_query_params 运行多个语句,但您仍然可以在没有回退到 pg_query 的情况下获得事务支持
<?php
$connection = pg_connect("host=127.0.0.1 port=5432 dbname=foo user=bar password=baz");
pg_query($connection, 'DROP TABLE IF EXISTS example');
pg_query($connection, 'CREATE TABLE example (col char(1))');
pg_query($connection, 'INSERT INTO example (col) VALUES (\'a\')');
pg_query($connection, 'BEGIN');
pg_query_params($connection, 'UPDATE example SET col = $1', array('b'));
pg_query_params($connection, 'UPDATE example SET col = $1', array('c'));
pg_query($connection, 'COMMIT');
?>