ID: 41622 Updated by: [EMAIL PROTECTED] Reported By: andrea dot spacca at gmail dot com -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Linux PHP Version: 5.2.3 New Comment:
mysql> CREATE TABLE tbl (field); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 Previous Comments: ------------------------------------------------------------------------ [2007-06-07 12:49:10] andrea dot spacca at gmail dot com > Works just fine here. i've no doubt, otherwise you'd open the bug before me > (And apparently everywhere else, since this is a very basic > functionality and you're the only one complaining.) that's false: i'm not the only one complaining, see http://pecl.php.net/bugs/bug.php?id=6030 and http://bugs.php.net/bug.php?id=36788. the fact that the complaints were ignored doesn't mean that the bug doesn't exist > Sorry, I don't understand what you're talking about. i'll be more explicit: [code] try { $createSql = 'CREATE TABLE tbl (field)'; $insertSql = array(); $insertSql[1] = 'INSERT INTO tbl (field) VALUES (1)'; $insertSql[2] = 'INSERT INTO tbl (field) VALUES (2)'; $insertSql[3] = 'INSERT INTO tbl (field) VALUES (3)'; $insertSql[4] = 'INSERT INTO tbl (field) VALUES (4)'; $insertSql[5] = 'INSERT INTO tbl (field) VALUES (5)'; $insertSql[6] = 'INSERT INTO tbl (field) VALUES (6)'; $insertSql[7] = 'INSERT INTO tbl (field) VALUES (7)'; $selectSql = 'SELECT field FROM tbl WHERE field BETWEEN 3 AND 5'; $bindedSql = 'SELECT field FROM tbl WHERE field BETWEEN :first AND :last'; $bindedValues = array(':first' => 3, ':last' => 5); $db = new PDO('sqlite:test.db'); $db->exec($createSql); foreach ($insertSql as $query) { $db->exec($query); } $testNoBind = $db->query($selectSql); $rowsNoBind = $testNoBind->fetchAll(); var_dump($rowsNoBind); $testWithBind = $db->prepare($bindedSql); $testWithBind->execute($bindedValues); $rowsWithBind = $testWithBind->fetchAll(); var_dump($rowsWithBind); $db = NULL; } catch (Exception $e) { var_dump($e); } [/code] [expected] array(3) { [0]=> array(2) { ["field"]=> string(1) "3" [0]=> string(1) "3" } [1]=> array(2) { ["field"]=> string(1) "4" [0]=> string(1) "4" } [2]=> array(2) { ["field"]=> string(1) "5" [0]=> string(1) "5" } } array(3) { [0]=> array(2) { ["field"]=> string(1) "3" [0]=> string(1) "3" } [1]=> array(2) { ["field"]=> string(1) "4" [0]=> string(1) "4" } [2]=> array(2) { ["field"]=> string(1) "5" [0]=> string(1) "5" } } [/expected] [result] array(3) { [0]=> array(2) { ["field"]=> string(1) "3" [0]=> string(1) "3" } [1]=> array(2) { ["field"]=> string(1) "4" [0]=> string(1) "4" } [2]=> array(2) { ["field"]=> string(1) "5" [0]=> string(1) "5" } } array(0) { } [/result] is it more clear now? ------------------------------------------------------------------------ [2007-06-07 10:20:05] [EMAIL PROTECTED] >i thought that PDOStatement::queryString will change will executing > the PDOStatement. Well, you were wrong. >obviously it isn't so, otherwise i hadn't open the bug >i haven't yet tested it on another enviroment, but on the one i'm >working it doesn't work. Works just fine here. (And apparently everywhere else, since this is a very basic functionality and you're the only one complaining.) >have i to open another bug showing the difference making the query >strainght with no binding and without it? (the first works, not the >latter) Sorry, I don't understand what you're talking about. ------------------------------------------------------------------------ [2007-06-07 10:15:16] andrea dot spacca at gmail dot com > Binds are processed by the database drivers (where available), so > $tmp->queryString contains original query, not the processed one. i thought that PDOStatement::queryString will change will executing the PDOStatement. > And you code works just fine when table > exists and contains requested data. obviously it isn't so, otherwise i hadn't open the bug i haven't yet tested it on another enviroment, but on the one i'm working it doesn't work. have i to open another bug showing the difference making the query strainght with no binding and without it? (the first works, not the latter) ------------------------------------------------------------------------ [2007-06-07 10:04:02] [EMAIL PROTECTED] >$tmp->quetryString haven't the :placeholder binded to the value >passed in execute(), so the query won't be a valid one and >$tmp->fetchAll() will be empty Binds are processed by the database drivers (where available), so $tmp->queryString contains original query, not the processed one. And you code works just fine when table exists and contains requested data. ------------------------------------------------------------------------ [2007-06-07 10:03:59] andrea dot spacca at gmail dot com i haven't put the example in the code but the problem raises both with named and "anonymous" placeholders ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41622 -- Edit this bug report at http://bugs.php.net/?id=41622&edit=1