File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ PDO PgSQL Bug #62593 (Emulate prepares behave strangely with PARAM_BOOL)
3+ --SKIPIF--
4+ <?php
5+ if (!extension_loaded ('pdo ' ) || !extension_loaded ('pdo_pgsql ' )) die ('skip not loaded ' );
6+ require dirname (__FILE__ ) . '/config.inc ' ;
7+ require dirname (__FILE__ ) . '/../../../ext/pdo/tests/pdo_test.inc ' ;
8+ PDOTest::skip ();
9+ ?>
10+ --FILE--
11+ <?php
12+ require dirname (__FILE__ ) . '/../../../ext/pdo/tests/pdo_test.inc ' ;
13+ $ db = PDOTest::test_factory (dirname (__FILE__ ) . '/common.phpt ' );
14+ $ db ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , true );
15+ $ db ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_SILENT );
16+ $ errors = array ();
17+
18+ $ query = $ db ->prepare ('SELECT :foo IS FALSE as val_is_false ' );
19+ $ query ->bindValue (':foo ' , true , PDO ::PARAM_BOOL );
20+ $ query ->execute ();
21+ $ errors [] = $ query ->errorInfo ();
22+
23+ $ query ->bindValue (':foo ' , 0 , PDO ::PARAM_BOOL );
24+ $ query ->execute ();
25+ $ errors [] = $ query ->errorInfo ();
26+
27+ $ query ->bindValue (':foo ' , false , PDO ::PARAM_BOOL );
28+ $ query ->execute ();
29+ $ errors [] = $ query ->errorInfo ();
30+
31+ $ expect = 'No errors found ' ;
32+
33+ foreach ($ errors as $ error )
34+ {
35+ if (strpos ('Invalid text representation ' , $ error [2 ]) !== false )
36+ {
37+ $ expect = 'Invalid boolean found ' ;
38+ }
39+ }
40+ echo $ expect ;
41+ ?>
42+ --EXPECTF--
43+
44+ No errors found
You can’t perform that action at this time.
0 commit comments