Heim  >  Artikel  >  Backend-Entwicklung  >  php使用sql数据库 获取字段问题介绍_PHP教程

php使用sql数据库 获取字段问题介绍_PHP教程

WBOY
WBOYOriginal
2016-07-21 14:59:04625Durchsuche

在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字段
这个很受用,解决我的难题!

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/328178.htmlTechArticle在PB开发过程中,由于数据库中使用了 ntext字段,出现以下提示错误,郁闷了很长时间找不到解决方案,后查阅大量资料, 终于明白: PB报...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn