1--TEST-- 2PDO Common: Bug #65946 (pdo_sql_parser.c permanently converts values bound to strings) 3--EXTENSIONS-- 4pdo 5--SKIPIF-- 6<?php 7$dir = getenv('REDIR_TEST_DIR'); 8if (false == $dir) die('skip no driver'); 9require_once $dir . 'pdo_test.inc'; 10PDOTest::skip(); 11?> 12--FILE-- 13<?php 14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 16$db = PDOTest::factory(); 17$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); 18$db->exec('CREATE TABLE test65946(id int)'); 19$db->exec('INSERT INTO test65946 VALUES(1)'); 20switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { 21 case 'dblib': 22 $sql = 'SELECT TOP :limit * FROM test65946'; 23 break; 24 case 'odbc': 25 $sql = 'SELECT TOP (:limit) * FROM test65946'; 26 break; 27 case 'firebird': 28 $sql = 'SELECT FIRST :limit * FROM test65946'; 29 break; 30 case 'oci': 31 //$sql = 'SELECT * FROM test65946 FETCH FIRST :limit ROWS ONLY'; // Oracle 12c syntax 32 $sql = "select id from (select a.*, rownum rnum from (SELECT * FROM test65946) a where rownum <= :limit)"; 33 break; 34 default: 35 $sql = 'SELECT * FROM test65946 LIMIT :limit'; 36 break; 37} 38$stmt = $db->prepare($sql); 39$stmt->bindValue('limit', 1, PDO::PARAM_INT); 40if(!($res = $stmt->execute())) var_dump($stmt->errorInfo()); 41if(!($res = $stmt->execute())) var_dump($stmt->errorInfo()); 42var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 43?> 44--CLEAN-- 45<?php 46require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 47$db = PDOTest::factory(); 48PDOTest::dropTableIfExists($db, "test65946"); 49?> 50--EXPECT-- 51array(1) { 52 [0]=> 53 array(1) { 54 ["id"]=> 55 string(1) "1" 56 } 57} 58