|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-09 18:14 UTC] opendev at us dot ibm dot com
[2007-07-10 14:12 UTC] roland dot wintgen at t-online dot de
[2007-07-10 16:40 UTC] opendev at us dot ibm dot com
[2007-09-08 11:45 UTC] roland dot wintgen at t-online dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 08:00:02 2025 UTC |
Description: ------------ When you're connected to a database by PDO you are unable to execute a query which tries to run against another database within this connection by giving a correct database object name (database:sysmaster). Rather than creating a second PDO instance it should be possible to run such queries. This leads also to problems when trying to gather information from different databases in one query. select table1.column, table2.column from database1:table1, database2:table2 How would you write such queries? Reproduce code: --------------- <?php putenv('INFORMIXDIR=/home/informix'); echo "(1) database: stores_demo<br />\n"; $db = new PDO("informix:host=192.168.0.127;service=1536;database=stores_demo;server=ifx10;"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $query = "select odb_dbname from sysmaster:sysopendb where odb_iscurrent = 'Y'"; echo "$query<br />\n"; try { $sql = $db->query($query); $sql->setFetchMode(PDO::FETCH_NAMED); var_dump($sql->fetch()); } catch (Exception $e) { echo $e->getMessage(); } $db = null; echo "<br />\n"; echo "<br />\n"; // // // // // // // // // // // // // // // // // // // // // // // // // // // echo "(2) database: sysmaster<br />\n"; $db = new PDO("informix:host=192.168.0.127;service=1536;database=sysmaster;server=ifx10;"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $query = "select odb_dbname from sysopendb where odb_iscurrent = 'Y'"; echo "$query<br />\n"; try { $sql = $db->query($query); $sql->setFetchMode(PDO::FETCH_NAMED); $dbsname = $sql->fetch(); printf("result: %s<br />\n", $dbsname["odb_dbname"]); } catch (Exception $e) { echo $e->getMessage(); } $db = null; ?> Expected result: ---------------- Both queries should return the actual selected database as specified by the DSN connection string. Actual result: -------------- (1) database: stores_demo select odb_dbname from sysmaster:sysopendb where odb_iscurrent = 'Y' SQLSTATE[42000]: Syntax error or access violation: -201 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -201. (SQLPrepare[-201] at /usr/local/src/php-5.2.3/ext/pdo_informix/informix_driver.c:131) (2) database: sysmaster select odb_dbname from sysopendb where odb_iscurrent = 'Y' result: sysmaster