php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57737 specifying database object name in query doesn't work
Submitted: 2007-07-08 13:15 UTC Modified: 2007-09-08 11:45 UTC
From: roland dot wintgen at t-online dot de Assigned:
Status: Closed Package: PDO_INFORMIX (PECL)
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: roland dot wintgen at t-online dot de
New email:
PHP Version: OS:

 

 [2007-07-08 13:15 UTC] roland dot wintgen at t-online dot de
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-09 18:14 UTC] opendev at us dot ibm dot com
This is caused by a parsing issue at the PDO layer and has been reported in http://pecl.php.net/bugs/bug.php?id=7033.

A fix has been made and it is currently being tested.  A release should be made to PDO soon once testing is completed.
 [2007-07-10 14:12 UTC] roland dot wintgen at t-online dot de
as I can see, the relating bug in PDO exists for more than one year now and I don't see any patch in CVS for it. Is there any chance that someone is working on this and release a new version in a reasonable time? Even the latest version of PDO is dated 2006-05-01.
 [2007-07-10 16:40 UTC] opendev at us dot ibm dot com
Sorry I wasn't very clear in the previous comment.  There is a patch that has been written, but not uploaded to CVS as of yet.

We are currently testing it to make sure that it fixes this issue in PDO_INFORMIX, as well as in PDO_IBM.

Once it is determined that the patch works, it will be uploaded to CVS.  Though I don't have an exact date, this should take no more than a few weeks.
 [2007-09-08 11:45 UTC] roland dot wintgen at t-online dot de
with the new release of PHP 5.2.4 it now works
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC