合并两个查询结果
我有两个完全相同的数据库(postgres)。现在,我想知道是否有某种方法可以执行以下操作:
$res1 = pg_query($connFirstDatabase, $query) or die('Query failed: ' . pg_last_error());
$res2 = pg_query($connSecondDatabase, $query) or die('Query failed: ' . pg_last_error());
$result = merged res1 and res2;
//我想知道是否有办法执行此操作,因为稍后我有一个工作php 代码负责处理 $result 变量。
先感谢您。
PS 我确实搜索过这个问题是否已经存在,但没有找到相关的答案。另外,如果有人在正确的方向上打勾以寻找解决方案就足够了。
I have two databases (postgres) that are absolutely the same. Now, I was wondering if there is some way to do the following:
$res1 = pg_query($connFirstDatabase, $query) or die('Query failed: ' . pg_last_error());
$res2 = pg_query($connSecondDatabase, $query) or die('Query failed: ' . pg_last_error());
$result = merged res1 and res2;
//I wonder if there is a way to do this, cause later on I have a working php code which takes care of the $result variable.
Thank you in advance.
P.S. I did search if this question already exist, and didn't find a related answer. Also, it would be enough if someone just gives me a tick in right direction to look for a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 pg_fetch_all() 创建两个数组,并使用 array_merge组合两个数组。
Create two arrays, using pg_fetch_all(), and use array_merge to combine both arrays.