Solution to TEXT field being truncated when querying SQL Server or Sybase in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:47:28
Original
1430 people have browsed it

Author: Wenlong Wu
1. For MS SQL SERVER database
There are two solutions, as follows:
Modify php.ini to achieve: 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.
; 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 semicolon in front, then save and restart the WEB server That’s it.
From the above two options, you 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 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);
}
Execute SET TEXTSIZE before querying in PHP Suitable size: Just execute
before SELECT mssql_query("SET TEXTSIZE 65536");
From the above PHP source code, you can see that SET TEXTSIZE is actually executed :)
2. For Sybase database
Since this extension does not have options like SQL SERVER to configure in php.ini, the only way is to use the second method above, that is:
Execute before SELECT
  sybase_query("SET TEXTSIZE 65536");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319932.htmlTechArticleAuthor: Wenlong Wu 1. There are two solutions for MS SQL SERVER database, as follows: Modify php.ini to Implementation: Open php.ini, you can see two options: mssql.textsize and mssql.textlimit...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template