php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56878 query parser doesn't grok "SELECT id FROM SAMPLE:test"
Submitted: 2006-03-06 10:20 UTC Modified: 2008-09-12 10:58 UTC
From: kfbombar at us dot ibm dot com Assigned:
Status: Closed Package: PDO (PECL)
PHP Version: 5.1.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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kfbombar at us dot ibm dot com
New email:
PHP Version: OS:

 

 [2006-03-06 10:20 UTC] kfbombar at us dot ibm dot com
Description:
------------
If you use a database name with the table name you get an error in the driver.  It does not matter if this name is remote, local or the current database.  I have seen this in different drivers including pdo_odbc and pdo_informix.  They all behave the same way.

Reproduce code:
---------------
<?php
        $conn = new PDO('odbc:SAMPLE', 'uname', 'pass');
        $conn->exec('CREATE TABLE test (id INT)');
        $conn->exec('INSERT INTO test(id) VALUES (1)');
        $sql  = "SELECT id FROM SAMPLE:test";
        $stmt = $conn->query($sql);
        $num  = $stmt->fetch( PDO::FETCH_BOTH );
        print "Counted $num rows after $action: $num[0].\n";
?>

Expected result:
----------------
Counted Array rows after : 1.

Actual result:
--------------
Fatal error: Call to a member function fetch() on a non-object in ~/b.php on line 9

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-13 22:38 UTC] jasper at album dot co dot nz
Wouldn't standard SQL be:

  $sql  = "SELECT id FROM SAMPLE.test";

(period rather than colon)
 [2006-03-14 14:07 UTC] kfbombar at us dot ibm dot com
We thought that the issue is the delimiter that PDO is using for param passing.  For example, "SELECT * FROM dbname:table" would be parsed into "SELECT * FROM dbname".  Let me know if I am wrong in my thoughts.  

Also, Informix uses the following syntax: dbname:owner.table

Thanks.
 [2006-03-27 17:48 UTC] kfbombar at us dot ibm dot com
Any update on the issue on why the SELECT query is being parsed incorrectly?
 [2006-04-09 01:35 UTC] wez@php.net
re-summarize
 [2006-04-12 13:00 UTC] iani at us dot ibm dot com
Informix has the ability to select data from tables that are not in the current database.  The Informix syntax for a distributed query looks like :-

SELECT * FROM  DBNAME@DBSERVER:TABLENAME 

or if the database is within the same Informix instance 

SELECT * FROM DBNAME:TABLENAME

The problem is that ':' is used to denote a binding param in PDO . PDO will rewrite the above statment to look like :-

SELECT * FROM DBNAME?

which is incorrect and generates a syntax error from Informix even thou the initial syntax ( SELECT * FROM DBNAME:TABNAME ) is valid.
 [2006-06-14 12:25 UTC] iani at us dot ibm dot com
Is any more info required ?
 [2006-09-19 14:46 UTC] iani at us dot ibm dot com
Maybe the query re-writing within PDO should just do param replacement after the WHERE clause . 

eg:

SELECT * FROM DB:CUSTOMER WHERE CUSTNO=:MYCUST;

Currently PDO re-writes the above as 

SELECT * FROM DB:? WHERE CUSTNO=?
 [2007-01-24 17:43 UTC] iani at us dot ibm dot com
Any update ?
 [2007-10-15 13:05 UTC] webmaster at smwebdesigns dot com
Any update on this?
 [2008-05-07 12:13 UTC] iani at us dot ibm dot com
This appears to have been addressed in PHP 5.2.4 . 
See also pecl bug# 11566
 [2008-09-12 10:58 UTC] johannes at schlueters dot de
"This appears to have been addressed in PHP 5.2.4" -> closing then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC