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