From a8d99f2228cc042c8410553f5f3ec375148552f5 Mon Sep 17 00:00:00 2001
From: Meik Sievertsen <acydburn@phpbb.com>
Date: Fri, 12 May 2006 20:52:58 +0000
Subject: - introduce new function build_url to easily build a valid url from
 the user->page object as well as optionally removing certain keys - changed
 attachment config to utilize the config build methods - cleaned up
 posting.php - the submit/delete_post functions are now usable
 (functions_posting.php) - adjusted header icons (transparency) - a bunch of
 fixes for mssql - bug fixes

git-svn-id: file:///svn/phpbb/trunk@5902 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/includes/db/mssql.php | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

(limited to 'phpBB/includes/db/mssql.php')

diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index e1082d282c..5d6095e502 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -98,7 +98,6 @@ class dbal_mssql extends dbal
 		{
 			global $cache;
 
-
 			// EXPLAIN only in extra debug mode
 			if (defined('DEBUG_EXTRA'))
 			{
@@ -315,17 +314,33 @@ class dbal_mssql extends dbal
 	*/
 	function _sql_error()
 	{
-
 		$error = array(
 			'message'	=> @mssql_get_last_message($this->db_connect_id),
 			'code'		=> ''
 		);
 
-		$result_id = @mssql_query('SELECT @@ERROR as errno', $this->db_connect_id);
+		// Get error code number
+		$result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
 		if ($result_id)
 		{
 			$row = @mssql_fetch_assoc($result_id);
-			$error['code'] = $row['errno'];
+			$error['code'] = $row['code'];
+			@mssql_free_result($result_id);
+		}
+
+		// Get full error message if possible
+		$sql = 'SELECT CAST(description as varchar(255)) as message 
+			FROM master.dbo.sysmessages
+			WHERE error = ' . $error['code'];
+		$result_id = @mssql_query($sql);
+		
+		if ($result_id)
+		{
+			$row = @mssql_fetch_assoc($result_id);
+			if (!empty($row['message']))
+			{
+				$error['message'] .= '<br />' . $row['message'];
+			}
 			@mssql_free_result($result_id);
 		}
 
-- 
cgit v1.2.1