为什么 TEXT 列只返回 4096 字节


Why TEXT column returns only 4096 bytes?

我用 mssql_query() 存储了一个长文本;

并使用数据类型为"文本"的字段。

我尝试使用 str_repeat() 使用不同的长字符串,页面需要很长时间,但最终提交结果。但是,当我检索结果时,无论如何,我只得到 4096 字节。我也试图通过管理工作室检索价值,它得到了相同的结果。

在我看来,这对我来说是一个存储问题。请提供一些建议...我很困惑。

编辑这些问的人,这就是我正在使用的:

function sql_escape($sql) { 
        /* De MagicQuotes */ 
    $fix_str        = stripslashes($sql); 
    $fix_str    = str_replace("'","''",$sql); 
    $fix_str     = str_replace("'0","[NULL]",$fix_str); 
    return "'".$fix_str."'"; 
} 
$query=mssql_query('update prod_cat set htmlbottom='.sql_escape(str_repeat('''choose_cat ', 122000)).
    ' where ID=1'   );  
$query=mssql_query('select htmlbottom from prod_cat where ID=1');
$a=mssql_fetch_assoc($query);
echo strlen($a['htmlbottom']);

Microsoft的PHP驱动程序(供参考):http://www.microsoft.com/en-us/download/details.aspx?id=20098

但是,如果您不想(或不能)更改驱动程序,请从此站点:

You need to increase the maximum size of a text column to be returned from
SQL Server by PHP. You can do this with a simple SQL query:
    SET TEXTSIZE 2147483647
Which you can run with the following PHP (best run just after you make a
connection).
    mssql_query("SET TEXTSIZE 2147483647");
A better way to work around the issue is to change the "textlimit" and
"textsize" settings within php.ini, like so:
    mssql.textlimit = 2147483647
    mssql.textsize = 2147483647

MSSQL 驱动程序正在截断文本。 如果您无法更改数据类型、驱动程序等,这应该可以为您解决问题。