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