本文介绍了正在获取常规错误:4004常规SQL Server错误:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Laravel中的数据库中获取数据,但是却收到常规错误:4004常规SQL Server错误:"

I am trying to fetch data from my database in Laravel, however I am getting a "General error: 4004 General SQL Server error:"

我正在将Laravel-5与MSSQL一起使用.如果我使用DB对象从MSSQL获取数据,则无法获取xml和nvarchar字段,

I'm using Laravel-5 with MSSQL.If I use the DB object to fetch data from MSSQL I am not able to fetch xml and nvarchar fields,

我在下面找到了一个有用的链接,但是要实现这一点,我必须重写所有查询.还有其他办法吗?

I found a usefull link below, but to implement this I have to rewrite all my queries. Is there any other way?

https: //gullele.wordpress.com/2010/12/15/accessing-xml-column-of-sql-server-from-php-pdo

推荐答案

请尝试:

 $handle = getHandle();
 $handle->exec('SET QUOTED_IDENTIFIER ON');
 $handle->exec('SET ANSI_WARNINGS ON');
 $handle->exec('SET ANSI_PADDING ON');
 $handle->exec('SET ANSI_NULLS ON');
 $handle->exec('SET CONCAT_NULL_YIELDS_NULL ON');

OR

您还可以检查服务器配置:检查"/etc/freetds.conf"文件并更改tds版本并添加客户端字符集,然后在php.ini中检查mssql.charset和default_charset

You can also check the server configuration:check the "/etc/freetds.conf " file and change the tds version and add client charset then in php.ini please check mssql.charset and default_charset

在/etc/freetds.conf中:

in /etc/freetds.conf :

;tds version = 4.2
tds version = 8.0
client charset = UTF-8

在php.ini中:

mssql.charset = "UTF-8"
default_charset = "utf-8"

这篇关于正在获取常规错误:4004常规SQL Server错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 10:00