PHP/PDO/MSSQL如何获取错误信息? [英] PHP / PDO / MSSQL how to get error informations?
问题描述
我已经做了很多搜索,但是找不到关于我的问题的任何信息.我正在将PDO
与驱动程序PDO_DBLIB
一起使用,以访问MS SQL数据库.我通常使用准备好的语句,但是如果有任何查询失败,除了以下内容之外,我不会获得任何其他有关错误的信息:
General SQL Server error: Check messages from the SQL Server [241] (severity 16) [(null)]
有人对我如何检索有关该错误(语法错误在...)的更多信息有任何提示吗?
最诚挚的问候
迈克尔
要查找错误消息:
-- SQL 2005+
select * from sys.messages where message_id = 241
-- SQL 2000
select * from sysmessages where error = 241
由于某些原因,PDO似乎正在删除实际的错误消息文本,但是由于,因此您几乎可以肯定应该使用不同的库来连接到MSSQL.
I've done a lot of searching, but can't find anything about my issue. I'm using PDO
with Driver PDO_DBLIB
to access a MS SQL database. I generally use prepared statements, but if any query fails I don't get any additional information about the error except for this:
General SQL Server error: Check messages from the SQL Server [241] (severity 16) [(null)]
Does anyone have a hint as to how do I retrieve more information about the error (syntax error at...)?
best regards
Michael
To find the error message:
-- SQL 2005+
select * from sys.messages where message_id = 241
-- SQL 2000
select * from sysmessages where error = 241
It appears that PDO is removing the actual error message text for some reason, but since the documentation says that PDO_DBLIB is experimental, this may simply be a bug.
You should also be aware that DBLIB has been deprecated by Microsoft since SQL 2005, so you should almost certainly use a different library for connecting to MSSQL.
这篇关于PHP/PDO/MSSQL如何获取错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!