例如:
SELECT ID,ContactName, Phone FROM FDB1617
应该从所有5个数据库中获取数据;
以下代码可用于分页
public function execFetchPage($sql, $action, $firstrow = 1, $numrows = 1, $bindvars = array()) {
$query = 'SELECT * FROM (SELECT a.*, ROWNUM AS rnum FROM (' . $sql . ') a WHERE ROWNUM <= :sq_last) WHERE :sq_first <= RNUM';
array_push($bindvars, array(':sq_first', $firstrow, -1));
array_push($bindvars, array(':sq_last', $firstrow + $numrows - 1, -1));
$res = $this->execFetchAll($query, $action, $bindvars);
return($res);
}
请提前帮助和谢谢
答案 0 :(得分:0)
您可以使用database links和UNION
在返回单个结果集时发出多个查询。
CREATE DATABASE LINK link_name CONNECT TO username IDENTIFIED BY password USING connection_string;
...
然后:
SELECT ID, ContactName, Phone FROM table_name
UNION
SELECT ID, ContactName, Phone FROM table_name@link_name
UNION
...