: This article describes how Text fields in the MSSQL database are truncated in PHP. For more information about PHP tutorials, see. The MSSQL database is used in PHP, and the Text field is used in the database, so the problem arises. The data obtained from each query from the database is inexplicably truncated. at first, I thought I was using
PHP FrameworkThe length of the string is limited. later I found this is a silly idea, because when I submit data, I can submit all the string content to the database, but this occurs only when I read the data, so there is a similar issue in online search. Luck was quite good. I found a solution for my first search and decided to post it to my Blog for the occasional needs of myself and the majority of PHP enthusiasts.
There are two solutions:
1. modify php. ini to implement:
Open php. ini and you will 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, that is, the common request is truncated to 4 kB. change it to the appropriate size, remove the semicolon, and then save and restart the WEB server.
The range is 0-2147483647 bytes.
If (MS_ SQL _G (textlimit )! =-1 ){
Sprintf (buffer, "% 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 ));
Dbcmd (mssql. link, buffer );
Dbsqlexec (mssql. link );
Dbresults (mssql. link );
}
2. execute set textsize before executing the SELECT query in PHP:
Mssql_query ("SETTEXTSIZE65536 ");
From the above PHP source code, we can see that set textsize is actually executed.
If the above does not work, you can try to use the CAST function in the query statement.
The preceding section describes how Text fields in the MSSQL database are truncated in PHP, including PHP Framework Content. if you are interested in the PHP Tutorial, you can help.