|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-11-25 05:16 UTC] matthias dot djihangiroff at persona dot de
Description: ------------ Syntax Error in SQL with more than one Database in one SQL Reproduce code: --------------- Select field FROM database1:field1 alias1, outer database2:field2 alias2 Expected result: ---------------- SQL Result PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Sure: ( [0] => 42000 [1] => -201 [2] => [Informix][Informix ODBC Driver][Informix]A syntax error has occurred. (SQLPrepare[-201] at /tmp/pear/download/PDO_INFORMIX-1.2.6/informix_driver.c:131) ) Thats the content of the PDO ExceptionHi, I tried a very simple sample for this case: --TEST-- pdo_informix: Dual database test --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php require_once('fvt.inc'); class Test extends FVTTest { public function runTest() { $this->connect(); $this->prepareDB(); $sqlselect = "SELECT * FROM testdb1:TEST_15152_1 TAB1, testdb2:TEST_15152_2 TAB2"; $sth = $this->db->prepare($sqlline); $sth->execute(); while ($row = $sth->fetch()) { print_r($row); } } } $testcase = new Test(); $testcase->runTest(); ?> This went through successfully. But when I change the query from "SELECT * FROM testdb1:TEST_15152_1 TAB1, testdb2:TEST_15152_2 TAB2" to "SELECT * FROM testdb1:TEST_15152_1 TAB1, OUTER testdb2:TEST_15152_2 TAB2" I got error. The same is true when I tried this on server directly. You are also using OUTER keyword in your case. I suggest you to remove the OUTER keyword and then run your application. Regards, Ambrish BhargavaHi, Try this standalone sample: <?php abstract class FVTTest { public $default_dsn = "informix:testdb1"; public $default_user = "informix"; public $default_pass = "password"; public $db = null; public $dsn = null; public $user = null; public $pass = null; public function __construct( $_dsn = null , $_user = null , $_pass = null ) { if( $_dsn == null ) { $this->dsn = getenv('PDOTEST_DSN'); if ($this->dsn==null) $this->dsn = $this->default_dsn; } else { $this->dsn = $_dsn; } if( $_user == null ) { $this->user = getenv('PDOTEST_USER'); if ($this->user==null) $this->user = $this->default_user; } else { $this->user = $_user; } if( $_pass == null ) { $this->pass = getenv('PDOTEST_PASS'); if ($this->pass==null) $this->pass = $this->default_pass; } else { $this->pass = $_pass; } } public function connect($autoCommit=true) { $this->db = new PDO($this->dsn,$this->user,$this->pass,array( PDO::ATTR_AUTOCOMMIT => $autoCommit )); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER); $this->db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); return $this->db; } } class Test extends FVTTest { public function runTest() { $this->connect(); $this->prepareDB(); $sqlselect = "SELECT * FROM testdb1:TEST_15152_1 TAB1, testdb2:TEST_15152_2 TAB2"; $sth = $this->db->prepare($sqlline); $sth->execute(); while ($row = $sth->fetch()) { print_r($row); } } } $testcase = new Test(); $testcase->runTest(); ?>