xref: /PHP-8.4/ext/pdo/tests/bug_69356.phpt (revision c1fec9bb)
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': $from = ' FROM DUAL'; break;
32    case 'firebird': $from = ' FROM RDB$DATABASE'; break;
33    default: $from = ''; break;
34}
35$query .= $from;
36
37$stmt = $db->query($query);
38var_dump($stmt->debugDumpParams());
39?>
40--EXPECTF--
41SQL: [%s] SELECT '
42    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).
43    This is a debug function, which dump directly the data on the normal output.
44    Tip:
45    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).
46    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.
47'%S
48Params:  0
49NULL
50