Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43852 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87060 invoked from network); 5 May 2009 18:15:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 May 2009 18:15:41 -0000 Received: from [127.0.0.1] ([127.0.0.1:1279]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 38/8A-54546-D42800A4 for ; Tue, 05 May 2009 14:15:41 -0400 Authentication-Results: pb1.pair.com smtp.mail=massi@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=massi@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: massi@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:48815] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/F9-57065-1A33FF94 for ; Mon, 04 May 2009 14:27:47 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id D95A9504A3 for ; Mon, 4 May 2009 22:15:53 +0300 (IDT) Received: from lap-massi.localnet ([10.1.3.66]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 4 May 2009 21:27:40 +0300 Organization: Zend Technologies To: internals@lists.php.net Date: Mon, 4 May 2009 21:27:39 +0300 User-Agent: KMail/1.11.2 (Linux/2.6.28-11-generic; KDE/4.2.2; i686; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_bOz/JabPLiYuaeq" Message-ID: <200905042127.39595.massi@zend.com> X-OriginalArrivalTime: 04 May 2009 18:27:40.0998 (UTC) FILETIME=[024DFE60:01C9CCE6] Subject: Stored procedure error propagation from MSSQL to PDO From: massi@zend.com (Massimiliano Cavicchioli) --Boundary-00=_bOz/JabPLiYuaeq Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I could not work out a way to make an error occurred on a stored procedure on on MSSQL server (2005) propagate back into PHP using PDO and PDOStatement. My setup is the following: PHP 5.2.9 / PDO_DBLIB running on a CentOS 5.3 machine executing the most simple stored procedure on a MSSQL Server 2005 that only does RAISERROR(). Sample PHP code is attached. Can anyone address me to a best practices tutorial regarding this case? Thanks in advance, Massi. Massimiliano Cavicchioli Senior Support Engineer Zend Technologies, Ltd. Email:massi@zend.com Tel:+972.3.6139544 www.zend.com --Boundary-00=_bOz/JabPLiYuaeq Content-Type: application/x-php; name="mssql_test.php" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mssql_test.php" ;dbname=','',''); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);//Tried all modes $stmt = $db->prepare("EXEC TEST_ERROR"); echo '
';
	if (!$stmt) {
		echo "\nPDO::errorInfo():\n";
		print_r($db->errorInfo());
		exit();
	}
	$stmt->execute();
	//$db->exec("EXEC TEST_ERROR");
	echo 'I executed...\n';
	echo "\nPDOStatement::errorInfo():\n";
	print_r($stmt->errorInfo());
	//print_r($db->errorInfo());
}
catch (Exception $ex)
{
	echo "Failed execution:\n" . $ex->getMessage() . "\n"
}
?>

--Boundary-00=_bOz/JabPLiYuaeq--