Home > Article > Backend Development > Solution to the problem that the nvarchar field length is truncated to 255 when PHP connects to MSSQL, mssqlnvarchar_PHP tutorial
The example in this article describes the solution to the problem that the nvarchar field length is truncated to 255 when PHP connects to MSSQL. Share it with everyone for your reference. The specific analysis is as follows:
Newbies 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:
If there is a field summary in your article table that is nvarchar, then the command is:
About cast, the code is as follows:
expression is the target field
data_type is the data type to be converted
I hope this article will be helpful to everyone’s PHP programming design.