diff options
Diffstat (limited to 'ext/sqlite3/tests/exception_from_toString.phpt')
| -rw-r--r-- | ext/sqlite3/tests/exception_from_toString.phpt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ext/sqlite3/tests/exception_from_toString.phpt b/ext/sqlite3/tests/exception_from_toString.phpt new file mode 100644 index 0000000000..1d6ed39f2a --- /dev/null +++ b/ext/sqlite3/tests/exception_from_toString.phpt @@ -0,0 +1,39 @@ +--TEST-- +Check that exceptions from __toString() are handled correctly +--FILE-- +<?php + +class throws { + function __toString() { + throw new Exception("Sorry"); + } +} + +$db = new sqlite3(':memory:'); +$db->exec('CREATE TABLE t(id int, v varchar(255))'); + +$stmt = $db->prepare('INSERT INTO t VALUES(:i, :v)'); +$stmt->bindValue('i', 1234); +$stmt->bindValue('v', new throws); + +try { + $stmt->execute(); +} catch (Exception $e) { + echo "Exception thrown ...\n"; +} + +try { + $stmt->execute(); +} catch (Exception $e) { + echo "Exception thrown ...\n"; +} + +$query = $db->query("SELECT * FROM t"); +while ($row = $query->fetchArray(SQLITE3_ASSOC)) { + print_r($row); +} + +?> +--EXPECT-- +Exception thrown ... +Exception thrown ... |
