Home > php教程 > php手册 > body text

PHP 连接 MSSQL 时 nvarchar 字段长度被截断为 255

WBOY
Release: 2016-06-13 09:49:10
Original
814 people have browsed it

PHP 连接 MSSQL 的新手经常遇到这个问题:数据库里面的 nvarchar 字段中数据一切正常,但是用 PHP 查询出来却发现长度只有 255,我们都知道,在 MySQL 里面 varchar 的长度只有 255,但是 MSSQL 却不是,不会是 PHP 将 nvarchar 按照 MySQL 的 varchar 处理了吧!

 本文给出了解决方法:

select cast(目标字段 as text) from 表名
假如你的 article 表中有个字段 summary 为 nvarchar,那么命令为:

 代码如下 复制代码
select cast(summary as text) from article

关于 cast :

 代码如下 复制代码

CAST ( expression AS data_type )

expression 为目标字段
data_type 为要转换成的数据类型

 

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template