1--TEST--
2Check that exceptions from __toString() are handled correctly
3--SKIPIF--
4<?php require_once(__DIR__ . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8class throws {
9    function __toString() {
10        throw new Exception("Sorry");
11    }
12}
13
14$db = new sqlite3(':memory:');
15$db->exec('CREATE TABLE t(id int, v varchar(255))');
16
17$stmt = $db->prepare('INSERT INTO t VALUES(:i, :v)');
18$stmt->bindValue('i', 1234);
19$stmt->bindValue('v', new throws);
20
21try {
22    $stmt->execute();
23} catch (Exception $e) {
24    echo "Exception thrown ...\n";
25}
26
27try {
28    $stmt->execute();
29} catch (Exception $e) {
30    echo "Exception thrown ...\n";
31}
32
33$query = $db->query("SELECT * FROM t");
34while ($row = $query->fetchArray(SQLITE3_ASSOC)) {
35    print_r($row);
36}
37
38?>
39--EXPECT--
40Exception thrown ...
41Exception thrown ...
42