note 53572 added to function.mssql-get-last-message
| From: | klaus dot kuehne at gga-hannover dot de | Date: | Mon, 06 Jun 2005 11:27:21 +0000 |
| Subject: | note 53572 added to function.mssql-get-last-message | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90004@lists.php.net to get a copy of this message | ||
MSSQL_GET_LAST_MESSAGE() has the major disadvantage, that only the last row of the SQLServer
message will be returned. And in most cases, this last row has no significant information or is even
empty.
In the meanwhile, I migrated my PHP-SQLServer application from MSSQL to ODBC, and now I use
ODBC_ERRORMSG() instead of MSSQL_GET_LAST_MESSAGE(). And this function works o.k.
I think that's a good idea to use ODBC instead of the native database interfaces. The
performance seems to be at the same level. And your application can easily ported to other database
systems.
The only minus of ODBC vs. MSSQL known to me is that ODBC cannot process return values of stored
procedures. No problem for most developers!
Regards,
Klaus
P.S.: Here is a small workaround for, the malfunctioning of MSSQL_GET_LAST_MESSAGE:
function get_sql_error ($con) {
$sql = "select @@ERROR as code";
$result = mssql_query($sql, $con);
$row = mssql_fetch_array($result);
$code = $row["code"]; // error code
$sql = "select cast (description as varchar(255)) as errtxt from
master.dbo.sysmessages where error = $code and msglangid = 1031"; // german
$result = mssql_query($sql, $con);
$row = mssql_fetch_array($result);
if ($row)
$text = $row["errtxt"]; // error text (with placeholders)
else
$text = "onknown error";
mssql_free_result($result);
return "[$code] $text";
}
----
Manual Page -- http://www.php.net/manual/en/function.mssql-get-last-message.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53572
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53572&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53572&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53572&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53572&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53572&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53572&report=yes
Search -- http://master.php.net/manage/user-notes.php