【发布时间】:2017-04-12 18:52:05
【问题描述】:
我正在使用test.php?id=2,4,5,6,7 之类的 URL 发送参数
并使用以下 php :
$id_array = $_GET['id'];
$id_array = explode(',', $id_array);
pg_prepare($conn, 'test', 'select 1 from my_test_table where id = ANY ($1)');
pg_execute($conn, 'test', array($id_array);
我不断得到类似的东西
malformed array literal: "["73","123","412"]"
和类似的错误。我无法弄清楚将数组传递给我的 pg_execute 的正确方法,但我需要确保在进行插入之前所有的 id 都在数据库中。
具体来说,我正在尝试在 postgres 数据库中插入一个 int 数组。
有人可以帮忙吗?
我也试过了
json_encode(explode(',', $id_array));
【问题讨论】:
标签: php sql arrays postgresql