MSSQL database was used in PHP, and it happened that Text type fields were used in the database, so the problem arose. Every time I query the data from the database, it is always truncated inexplicably. At first, I thought that the PHP framework I was using had a limit on the length of the string. Later I found out that this was a stupid idea, because when submitting the data The whole string content can be submitted to the database, but this phenomenon only occurs when reading, so I searched online to see if there are similar problems. I was lucky enough to find the solution on my first search, so I decided to repost it on my blog for the occasional needs of myself and the majority of PHP enthusiasts.
There are two solutions, as follows:
1. Modify php.ini to achieve:
Open php.ini, you can see two options: mssql.textsize and mssql.textlimit:
; Valid range 0 - 2147483647. Default = 4096 .
;mssql.textlimit = 4096
; Valid range 0 - 2147483647. Default = 4096.
;mssql.textsize = 4096
You can see that the default configuration is 4096 bytes, which is often truncated to 4K. Change it to a suitable size, remove the preceding semicolon, then save and restart the WEB server.
From the above two options, you can see that the range is: 0 - 2147483647 bytes. "
%li" ,MS_SQL_G(textlimit));if(DBSETOPT(mssql
.link,DBTEXTLIMIT,buffer) ==FAIL){ efree(hashed_details);
dbfreelogin(mssql.login);RETURN_FALSE;}}if(MS_SQL_G(textsize) !=-
1
){sprintf
(buffer
,
"
SETTEXTSIZE%li",MS_SQL_G(textsize));dbcm d(mssql.link
,buffer);dbsqlexec(mssql.link);dbresults(mssql.link);}
2. Execute before executing SELECT query in PHP SET TEXTSIZE: mssql_query("
SETTEXTSIZE65536");
As you can see from the above PHP source code, SET TEXTSIZE is actually executed.
If the above does not work, you can try to use the CAST function in the query statement.
The above introduces the solution to the problem of Text type fields in MSSQL database being truncated in PHP, including the content of PHP framework. I hope it will be helpful to friends who are interested in PHP tutorials.