各位好,我的数据完整的存数据库中(10000字左右),用php 获取数据获取该字段内容时,为什么只能获取前部份内容,而获取的不是所有的内容
回复讨论(解决方案)
字段是什么类型的?
怎么会啊 你是不是用的var_dump输出的,然后安装了xdebug,安装xdebug用函数var_dump打印时会截断
数据库是mssql,字段是text类型的,这样取数据 $v['memo']=iconv("gbk", "UTF-8",$memo);然后直接echo,print_r都试了,显示的内容不全,但是确定已经在数据库里了
代码如下,其中memo是mssql的text
function getInfo()
{
ini_set('mssql.datetimeconvert','0');
ini_set("mssql.textsize",200000);
ini_set("mssql.textlimit",200000);
$sql="SET TEXTSIZE 65536";
$this->db->query($sql);
$id = getgpc('id', 'G');
$sql="select * from [peihuo].[dbo].[S_advset] where id=".$id;
$arrdata = $this->db->fetch_array_all($sql);
if($arrdata)
{
foreach($arrdata as $k => $v)
{
$memo=$v['memo'];
$v['title']=iconv("gbk", "UTF-8",$v['title']);
$v['memo']=iconv("gbk", "UTF-8",$memo);
echo $v['memo']."
";//这里不能读取所有内容
$arr[$k] = $v;
}
}
return $arr;
}
echo base64_encode($v['memo']);
贴出结果
如果贴不下,就
file_put_contents('test.txt', $v['memo']);
把 test.txt 放到网盘上
版主,我已经把文件传上去了网盘上
http://yun.baidu.com/xcloud/csdn/pan/disk/home
那个公路运输合同是我放入到数据中内容,那个text.txt是file_put_contents('test.txt', $v['memo']);的内容,编辑器用的是fckeditor
你放的地方不对!
csdn 的网盘是无法分享的,只有你自己看的到
有点奇怪,那你在phpmyadmin中能看到数据库的数据是完整的吗?
如果在phpmyadmin中看到的都不完整,就是插入时已经被截取了。
数据库字段类型是varchar的话那个长度得设置成10000以上 但估计没办法设置那么多
所以字段类型得改成text
可能写入的时候就被截取了
还有不要用echo 用print_r来看
存入数据库的数据是否有问题?已经被截断?
读取的时候,不应该被截断,除非你字符转换。
各们老大,我把文件传到我的服务去上了,http://www.56phw.com/test.rar,数据库中肯定有记录,是全的,就是echo 或print_r时,内容显示不全,只能显示前面大约2000字左右,数据库是mssql2005
function getInfo()
{
ini_set('mssql.datetimeconvert','0');
ini_set("mssql.textsize",200000);
ini_set("mssql.textlimit",200000);
$sql="SET TEXTSIZE 65536";
$this->db->query($sql);
$id = getgpc('id', 'G');
$sql="select * from [peihuo].[dbo].[S_advset] where id=".$id;
$arrdata = $this->db->fetch_array_all($sql);
if($arrdata)
{
foreach($arrdata as $k => $v)
{
$memo=$v['memo'];
$v['title']=iconv("gbk", "UTF-8",$v['title']);
$v['memo']=iconv("gbk", "UTF-8",$memo);//这里是内容,就是这里显示不全,
$arr[$k] = $v;
}
}
return $arr;
}
你放个 word 文档是什么意思?
就是把那个WORD的内容放到mssql表的memo字段中,是text类型的
你在 sql server 2005 的管理工具中能看到完整的内容吗?
ini_set("mssql.textsize",200000);
ini_set("mssql.textlimit",200000);
没有生效,默认是 4096
你确认用的是 php_mssql 扩展吗?
我确定在mssql2005中能看到完整的记录
ini_set("mssql.textsize",200000);
ini_set("mssql.textlimit",200000);
好像没有生效,不知道咋回事
看看你的数据库类定义
最近也遇到这个问题,不知道楼主解决没有。
同时还有直接执行Sql语句时会提示:message: 不能用 DB-Library (如 ISQL)或 ODBC 3.7 或更早版本将 ntext 数据或仅使用 Unicode 排序规则的 Unicode 数据发送到客户端。 (severity 16)
需要加 CASE(test1 as TEXT) as test 才行。
查了一下
在php.ini中有这么一句配置。你看对你有用没有。
; Valid range 0 - 2147483647. Default = 4096.
mssql.textsize = 20480
我也遇到了类似的问题 我的问题是 在进行查询的时候 我拼了一个巨长的sql字符串 存放在变量$sql中 然而在执行时报错了 我发现 这个$sql变量的长度是有限制的 如何才能完整赋值呢 求解啊 这个大sql可以少写至少几百行代码啊

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
