xref: /PHP-8.2/ext/pdo_mysql/tests/bug81037.phpt (revision b5a14e6c)
1--TEST--
2Bug #81037 PDO discards error message text from prepared statement
3--EXTENSIONS--
4pdo
5pdo_mysql
6--SKIPIF--
7<?php
8require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
9MySQLPDOTest::skip();
10?>
11--FILE--
12<?php
13require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14
15$pdo = MySQLPDOTest::factory();
16$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
18MySQLPDOTest::createTestTable($pdo);
19
20$sql = "SELECT id FROM test WHERE label = :par";
21$stmt = $pdo->prepare($sql);
22try {
23    $stmt->execute();
24} catch (PDOException $e) {
25    echo $e->getMessage(), "\n";
26}
27$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
28
29?>
30--CLEAN--
31<?php
32require __DIR__ . '/mysql_pdo_test.inc';
33MySQLPDOTest::dropTestTable();
34?>
35--EXPECT--
36SQLSTATE[HY093]: Invalid parameter number
37