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