1--TEST-- 2PDO PgSQL Bug #64953 (Postgres prepared statement positional parameter casting) 3--EXTENSIONS-- 4pdo_pgsql 5--SKIPIF-- 6<?php 7require __DIR__ . '/config.inc'; 8require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13echo "Test\n"; 14 15require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 16$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt'); 17$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); 18 19echo "Taken from the bug report:\n"; 20 21$st = $pdo->prepare('SELECT ?::char as i'); 22$st->bindValue(1, '1'); 23$st->execute(); 24var_dump($st->fetch()); // return false 25 26 27$st = $pdo->prepare('SELECT (?)::char as i'); 28$st->bindValue(1, '1'); 29$st->execute(); 30var_dump($st->fetch()); // return array(1) { ["i"]=> string(1) "1" } 31 32echo "Something more nasty:\n"; 33 34$st = $pdo->prepare("SELECT :int::int as i"); 35$st->execute(array(":int" => 123)); 36var_dump($st->fetch()); 37 38$st = $pdo->prepare("SELECT '''?'''::text as \":text\""); 39$st->execute(); 40var_dump($st->fetch()); 41 42?> 43Done 44--EXPECT-- 45Test 46Taken from the bug report: 47array(2) { 48 ["i"]=> 49 string(1) "1" 50 [0]=> 51 string(1) "1" 52} 53array(2) { 54 ["i"]=> 55 string(1) "1" 56 [0]=> 57 string(1) "1" 58} 59Something more nasty: 60array(2) { 61 ["i"]=> 62 string(3) "123" 63 [0]=> 64 string(3) "123" 65} 66array(2) { 67 [":text"]=> 68 string(3) "'?'" 69 [0]=> 70 string(3) "'?'" 71} 72Done 73