Solution to TEXT field truncation when querying SQL Server or Sybase in PHP

Source: Internet
Author: User

Author: Wenlong Wu
1. for ms SQL SERVER databases
There are two solutions:
Modify php. ini to achieve this: Open php. ini and 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, 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.
From the two options above, we can see that the range is 0-2147483647 bytes. In fact,-1 is also acceptable. Check the PHP source code and you will find that-1 indicates no limit :)
  
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, "set textsize % li", MS_ SQL _G (textsize ));
Dbcmd (mssql. link, buffer );
Dbsqlexec (mssql. link );
Dbresults (mssql. link );
}
Run the set textsize command before querying in PHP: run the command before SELECT.
Mssql_query ("set textsize 65536 ");
From the above PHP source code, we can see that it is actually executing set textsize :)
II. For Sybase databases
Because this extension is not configurable in php. ini as in SQL SERVER, the preceding method is used only:
Run
Sybase_query ("set textsize 65536 ");

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.