On 28 Sep 2005 04:21:07 -0700, "ssp" <ssp@planicsware.de> wrote:
[color=blue]
>Dear all,
>
>finally I found a solution (or better our sysadmin told me to read
>mysql manual user comments in detail;):
>
>the trick is: mysql trades BLOBs as kind of huge strings. so one can
>use LENGTH on a column to get its content-length and then read out
>using SUBSTRING sequentially.
>
>snippet (assuming that $__DB = PEAR:DB Connection is correctly
>initiated) :
><?
>$stQuery = "SELECT LENGTH(PIF_FILE_BLOB) FROM PIF WHERE PIF_ID=2";
>$iFileSize = $__DB->getOne($stQuery);
>
>$i=0;
>$iPos = 1; //Startposition
>$iLength = 4096; //Readbuffer size
>$iTotal = ($iFileSize/$iLength); //how many queries ?
>$iStatus = ceil($iTotal/20); //after 20 queries print out a char
>
>//open Output File Handle
>printf("Lade neu.exe [%d kB] [",ceil($iFileSize/1024));
>$oFileHandle = fopen('.dev/neu.exe','w');
>
>while (!isset($stRead) || $stRead!='') {
> $i++;
> $stQuery = sprintf("SELECT substring(PIF_FILE_BLOB,%d,%d) FROM PIF
>WHERE PIF_ID=2",$iPos,$iLength);
> $iPos+=$iLength;
> $stRead = $__DB->getOne($stQuery);
> fwrite($oFileHandle,$stRead);
> if ($i%$iStatus==0) echo "=";
>}
>echo "]";
>
>fclose($oFileHandle);
>
>?>
>
>
>This works very good for me[/color]
I've seen this sort of thing before. Adding some time to the actual
process to show progress makes the user believe it's going "faster"
than if they see nothing happening.
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one!
http://signup.databasix.com
================================================== =========================