Retrieve error from SQL Server in PHP -


i'm trying show users (in php) when block of sql actions commit failed reason. likes php dbo never gets error. simplification of actual code.

$conn = new pdo("dblib:host=$host; dbname=$db", $user, $pass);  $sql = "     begin tran         insert table (field) values (1)         insert table (field) values (2)         insert table (field) values ('this throw error')     commit     if @@error <> 0 begin         rollback         raiserror('nops.', 16, 1)     end";  try {     $rs = $conn->query($sql); } catch (pdoexception $e) {     echo 'it never gets here'; } 

how transaction not commited?


Comments