本文介绍了即使设置了INI值,PHP也会截断MSSQL Blob数据(4096b).我想念一个吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个PHP脚本,该脚本将遍历一个表并将每个记录中的varbinary(max) blob数据提取到一个外部文件中.该代码运行正常(我实际上使用相同的代码浏览了一些图像),除非文件超过4096b-数据恰好在4096处被截断.

I am writing a PHP script that goes through a table and extracts the varbinary(max) blob data from each record into an external file. The code is working perfectly (I used virtually the same code to go through some images) except when a file is over 4096b - the data is truncated at exactly 4096.

我修改了mssql.textlimitmssql.textsizeodbc.defaultlrl的值,但没有成功.

I've modified the values for mssql.textlimit, mssql.textsize, and odbc.defaultlrl without any success.

我在这里想念东西吗?

<?php 
 ini_set("mssql.textlimit" , "2147483647");
 ini_set("mssql.textsize" , "2147483647");
 ini_set("odbc.defaultlrl", "0");

 include_once('common.php'); //Connection to DB takes place here.
 $id=$_REQUEST['i'];
 $q = odbc_exec($connect, "Select id,filename,documentBin from Projectdocuments where id = $id"); 
 if (odbc_fetch_row($q)){

  echo "Trying $filename ... ";
  $fileName="projectPhotos/docs/".odbc_result($q,"filename");

  if (file_exists($fileName)){
   unlink($fileName);
  } 

     if($fh = fopen($fileName, "wb")) {
      $binData=odbc_result($q,"documentBin");
         fwrite($fh, $binData) ;
         fclose($fh);
         $size = filesize($fileName);
         echo ("$fileName<br />Done ($size)<br><br>");
     }else {
      echo ("$fileName Failed<br>");
     }
 } 
?>

输出

尝试... projectPhotos/docs/file2.zip完成(4096)

Trying ... projectPhotos/docs/file2.zip Done (4096)

尝试... projectPhotos/docsv3.pdf完成(4096)

Trying ... projectPhotos/docsv3.pdf Done (4096)

等.

推荐答案

而不是将odbc.defaultlrl设置为0,而是尝试将其设置为实际值:

Instead of setting odbc.defaultlrl to 0, try setting it to an actual value instead:

ini_set("odbc.defaultlrl", "100K");

这篇关于即使设置了INI值,PHP也会截断MSSQL Blob数据(4096b).我想念一个吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 11:00