xref: /PHP-8.2/ext/pdo_pgsql/tests/bug71885.phpt (revision 39131219)
1--TEST--
2Request #71855 (PDO placeholder escaping)
3--EXTENSIONS--
4pdo
5pdo_pgsql
6--SKIPIF--
7<?php
8require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
9require_once dirname(__FILE__) . '/config.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
15require_once dirname(__FILE__) . '/config.inc';
16$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
17$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
18$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM);
19
20foreach ([false, true] as $emulate) {
21    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate);
22
23    try {
24        $stmt = $db->prepare('select ?- lseg \'((-1,0),(1,0))\'');
25        $stmt->execute();
26    } catch (PDOException $e) {
27        var_dump('ERR');
28    }
29
30    $stmt = $db->prepare('select ??- lseg \'((-1,0),(1,0))\'');
31    $stmt->execute();
32
33    var_dump($stmt->fetch());
34}
35
36?>
37==OK==
38--EXPECT--
39string(3) "ERR"
40array(1) {
41  [0]=>
42  string(1) "1"
43}
44array(1) {
45  [0]=>
46  string(1) "1"
47}
48==OK==
49