Home  >  Article  >  Backend Development  >  php使用sql数据库 获取字段问题介绍_php技巧

php使用sql数据库 获取字段问题介绍_php技巧

WBOY
WBOYOriginal
2016-05-17 08:55:49785browse

在PB开发过程中,由于数据库中使用了 ntext字段,出现以下提示错误,郁闷了很长时间找不到解决方案,后查阅大量资料,终于明白:
PB报错:
不能用 DB-Library(如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使用 Unicode 排序规则的 Unicode 数据发送到客户端。
————————————————
由于sql server中,ntext和nvarchar字段是用unicode编码存储内容的,因此php通过mssql扩展读取带ntext和nvarchar类型字段的时候会抱错。

如果 title 字段类型为 nvarchar,content 字段类型为 ntext ,那么下面的sql语句会报错:
select title,content from article

正确的写法是:
select convert(varchar(255),title) as title, convert(text,content) as content from article
或者不使用ntext字段
这个很受用,解决我的难题!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn