1--TEST-- 2__toString() exception during PDO Sqlite parameter binding 3--EXTENSIONS-- 4pdo_sqlite 5--FILE-- 6<?php 7 8class throws { 9 function __toString() { 10 throw new Exception("Sorry"); 11 } 12} 13 14$db = new PDO('sqlite::memory:'); 15$db->exec('CREATE TABLE t(id int, v varchar(255))'); 16 17$stmt = $db->prepare('INSERT INTO t VALUES(:i, :v)'); 18$param1 = 1234; 19$stmt->bindValue('i', $param1); 20$param2 = "foo"; 21$stmt->bindParam('v', $param2); 22 23$param2 = new throws; 24 25try { 26 $stmt->execute(); 27} catch (Exception $e) { 28 echo "Exception thrown ...\n"; 29} 30 31try { 32 $stmt->execute(); 33} catch (Exception $e) { 34 echo "Exception thrown ...\n"; 35} 36 37$query = $db->query("SELECT * FROM t"); 38while ($row = $query->fetch(PDO::FETCH_ASSOC)) { 39 print_r($row); 40} 41 42?> 43--EXPECT-- 44Exception thrown ... 45Exception thrown ... 46