1--TEST--
2PDO Common: PDOStatement::debugDumpParams() with emulated prepares
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$db = PDOTest::factory();
13if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') die('skip pgsql has its own test for this feature');
14if (!@$db->getAttribute(PDO::ATTR_EMULATE_PREPARES) && !@$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true)) die('skip driver cannot emulate prepared statements');
15?>
16--FILE--
17<?php
18if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
19require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
20
21$db = PDOTest::factory();
22$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
23
24$stmt = $db->query('SELECT 1');
25
26// "Sent SQL" shouldn't display
27var_dump($stmt->debugDumpParams());
28
29$stmt = $db->prepare('SELECT :bool, :int, :string, :null');
30$stmt->bindValue(':bool', true, PDO::PARAM_BOOL);
31$stmt->bindValue(':int', 123, PDO::PARAM_INT);
32$stmt->bindValue(':string', 'foo', PDO::PARAM_STR);
33$stmt->bindValue(':null', null, PDO::PARAM_NULL);
34$stmt->execute();
35
36// "Sent SQL" should display
37var_dump($stmt->debugDumpParams());
38
39?>
40--EXPECT--
41SQL: [8] SELECT 1
42Params:  0
43NULL
44SQL: [34] SELECT :bool, :int, :string, :null
45Sent SQL: [26] SELECT 1, 123, 'foo', NULL
46Params:  4
47Key: Name: [5] :bool
48paramno=-1
49name=[5] ":bool"
50is_param=1
51param_type=5
52Key: Name: [4] :int
53paramno=-1
54name=[4] ":int"
55is_param=1
56param_type=1
57Key: Name: [7] :string
58paramno=-1
59name=[7] ":string"
60is_param=1
61param_type=2
62Key: Name: [5] :null
63paramno=-1
64name=[5] ":null"
65is_param=1
66param_type=0
67NULL
68