PHP query for SQL Server or Sybase when text fields are truncated _php tips

Source: Internet
Author: User
Tags mssql php source code sprintf sybase sybase database truncated
Author:wenlong Wu
One, for MS SQL Server database
There are two solutions, as follows:
Modify PHP.ini to implement: Open php.ini, you can see mssql.textsize,mssql.textlimit two options:

; 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 frequently encountered truncated to 4K, change it to the appropriate size, remove the preceding semicolon, and then save and then the Web server.
From the above two options can see the range is: 0-2147483647 bytes, in fact, 1 can also, check the PHP source code can be found-1 means unlimited:)
  
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);
}
The appropriate size to execute the set TEXTSIZE before querying in PHP: Just execute before select
Mssql_query ("SET textsize 65536");
From the above PHP source code can be seen in fact is also the implementation of SET TEXTSIZE:)
Second, for Sybase database
Since the extension does not have an option configurable like SQL Server in PHP.ini, only the second method above is used:
Executing before a Select
Sybase_query ("SET textsize 65536");
Related Article

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.