xref: /PHP-8.1/ext/pdo/tests/bug_69356.phpt (revision 74859783)
1--TEST--
2PDO Common: Bug #69356 (PDOStatement::debugDumpParams() truncates query)
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9if (!strncasecmp(getenv('PDOTEST_DSN'), 'oci', strlen('oci'))) die('skip query not supported');
10require_once $dir . 'pdo_test.inc';
11PDOTest::skip();
12?>
13--FILE--
14<?php
15if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
16require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
17
18$db = PDOTest::factory();
19$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
20$query = <<<'SQL'
21SELECT '
22    Dumps the information contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
23    This is a debug function, which dump directly the data on the normal output.
24    Tip:
25    As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example).
26    This will only dumps the parameters in the statement at the moment of the dump. Extra parameters are not stored in the statement, and not displayed.
27'
28SQL;
29
30switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
31    case 'oci':
32        $query .= ' FROM DUAL';
33        break;
34    case 'firebird':
35        $query .= ' FROM RDB$DATABASE';
36        break;
37}
38
39$stmt = $db->query($query);
40var_dump($stmt->debugDumpParams());
41?>
42--EXPECTF--
43SQL: [%s] SELECT '
44    Dumps the information contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
45    This is a debug function, which dump directly the data on the normal output.
46    Tip:
47    As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example).
48    This will only dumps the parameters in the statement at the moment of the dump. Extra parameters are not stored in the statement, and not displayed.
49'%S
50Params:  0
51NULL
52