facebook / facebook/hhvm

PDO::ATTR_ERRMODE attribute is ignored

Open
#7,134 1 comment 0 reactions 0 assignees View on GitHub
php5 incompatibility php7 incompatibility probably easy
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

It appears that HHVM always handles PDO exceptions as if error mode were set to `PDO::ERRMODE_EXCEPTION`, even when the error mode is explicitly set to `PDO::ERRMODE_SILENT`.
### HHVM Version

```
HipHop VM 3.12.1 (rel)
Compiler: tags/HHVM-3.12.1-0-gf516f1bb9046218f89885a220354c19dda6d8f4d
Repo schema: f2e5f39b2ad4a08bcbd90b5d8bcb580f40fba6c8
```
### Standalone code, or other way to reproduce the problem

```
$pdo = /* instantiate a PDO instance */;
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);

$query = "INSERT INTO Test (id,value) VALUES (1,2)";
$stmt = $pdo->prepare($query);
$success = $stmt->execute();
print ($success ? "success" : "failure") . "\n";
```
### Expected result

`failure` if the Test table already has a row with ID 1
### Actual result

`Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000] [1062] Duplicate entry '1' for key 'PRIMARY''`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.