Home >Backend Development >PHP Tutorial >When PHP connects to MSSQL, the nvarchar field length is truncated to 255_PHP tutorial

When PHP connects to MSSQL, the nvarchar field length is truncated to 255_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:46:251139browse

Novices who connect PHP to MSSQL often encounter this problem: the data in the nvarchar field in the database is normal, but when queried using PHP, the length is only 255. We all know that the length of varchar in MySQL is only 255, but in MSSQL But no, it’s not because PHP processes nvarchar according to MySQL’s varchar!

This article gives the solution:

select cast(target field as text) from table name
If there is a field summary in your article table that is nvarchar, then the command is:

The code is as follows
 代码如下 复制代码
select cast(summary as text) from article
Copy code

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

CAST ( expression AS data_type )


About cast:

The code is as follows Copy code
CAST ( expression AS data_type )

expression is the target field data_type is the data type to be converted
http://www.bkjia.com/PHPjc/632940.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/632940.htmlTechArticlePHP Newbies who connect to MSSQL often encounter this problem: the data in the nvarchar field in the database is all normal, but when using PHP After checking, we found that the length is only 255. We all know...
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