Solution to why Text type fields in MSSQL database are truncated in PHP

WBOY
Release: 2016-07-29 09:13:58
Original
1161 people have browsed it

MSSQL database was used in PHP, and it happened that Text type fields were used in the database, so the problem arose. Every time I query the data from the database, it is always truncated inexplicably. At first, I thought that the PHP framework I was using had a limit on the length of the string. Later I found out that this was a stupid idea, because when submitting the data The whole string content can be submitted to the database, but this phenomenon only occurs when reading, so I searched online to see if there are similar problems. I was lucky enough to find the solution on my first search, so I decided to repost it on my blog for the occasional needs of myself and the majority of PHP enthusiasts.
There are two solutions, as follows:
1. Modify php.ini to achieve:
Open php.ini, 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, which is often truncated to 4K. Change it to a suitable size, remove the preceding semicolon, then save and restart the WEB server.
From the above two options, you can see that the range is: 0 - 2147483647 bytes. "

%liSolution to why Text type fields in MSSQL database are truncated in PHP" ,MS_SQL_G(textlimit));if(DBSETOPT(mssql
Solution to why Text type fields in MSSQL database are truncated in PHP.
link,DBTEXTLIMIT,buffer) ==FAIL){ efree(hashed_details);
Solution to why Text type fields in MSSQL database are truncated in PHPdbfreelogin(mssql
.login);RETURN_FALSE;}}if(MS_SQL_G(textsize) !=-
Solution to why Text type fields in MSSQL database are truncated in PHP1
Solution to why Text type fields in MSSQL database are truncated in PHP){
sprintf
Solution to why Text type fields in MSSQL database are truncated in PHP(buffer
Solution to why Text type fields in MSSQL database are truncated in PHP,
Solution to why Text type fields in MSSQL database are truncated in PHP"
Solution to why Text type fields in MSSQL database are truncated in PHPSETTEXTSIZE%li
",MS_SQL_G(textsize));dbcm d(mssql.link
Solution to why Text type fields in MSSQL database are truncated in PHP,
buffer);dbsqlexec(mssql.link);dbresults(mssql.link);}
Solution to why Text type fields in MSSQL database are truncated in PHP
2. Execute before executing SELECT query in PHP SET TEXTSIZE: mssql_query("
Solution to why Text type fields in MSSQL database are truncated in PHPSETTEXTSIZE65536
");
Solution to why Text type fields in MSSQL database are truncated in PHP
As you can see from the above PHP source code, SET TEXTSIZE is actually executed.
Solution to why Text type fields in MSSQL database are truncated in PHPIf the above does not work, you can try to use the CAST function in the query statement.

The above introduces the solution to the problem of Text type fields in MSSQL database being truncated in PHP, including the content of PHP framework. I hope it will be helpful to friends who are interested in PHP tutorials.

Solution to why Text type fields in MSSQL database are truncated in PHP

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!