Section truncation of Text fields in the MSSQL database in PHP

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.