php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15771 COM: cannot pass value to image field by ado
Submitted: 2002-02-27 21:29 UTC Modified: 2004-09-28 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: darkwings at 263 dot net Assigned: wez (profile)
Status: No Feedback Package: Feature/Change Request
PHP Version: 5CVS OS: windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: darkwings at 263 dot net
New email:
PHP Version: OS:

 

 [2002-02-27 21:29 UTC] darkwings at 263 dot net
Since PHP can support COM and I usually use php in windows,
I try to use database like mssql through ado.
All things work properly but the image datatype of mysql cannot be set  correctly.
I use it just like this
<?
$dbconn=new COM("ADODB.Connection") or die ("connection create fail");
$dbconn->Open("Provider=sqloledb;Data Source=ndht;Initial Catalog=printers;User Id=printers;Password=printers;");
$fp=fopen("5.gif","r") or die ("file opening error");
$content = fread ($fp, filesize ("5.gif"));
fclose ($fp);
echo filesize ("5.gif");
$rec=new COM("ADODB.recordset");
$rec->open("select * from sav",$dbconn);
$rec->addnew();
$rec->fields["datas"]->AppendChunk($content);
$rec->update();
$rec->close();
$rec=null;
$dbconn->close();
$dbconn=null;
?>

I think that windows use two type text for strings and binary for the 8bit chars, but in php string are both of
these.
So when trans the data to mssql,the variables be string of
window first, and the information were lost.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-11 13:04 UTC] phanto@php.net
hmm, this is a bit difficult because strings become usually translated into unicode which is usually a good thing(tm) but unfortunatelly not in this case.
as i'm actually rewriting the whole thing for php5/ZE2 i don't think that i'll address this yet.

harald

ps: don't use ado, it's sloooooooooooow :)
 [2002-03-12 06:15 UTC] darkwings at 263 dot net
i think it is not necessary to rewrite,just use a function
like binarywrite() in asp(Active Server Page),
int binarywrite ($variant,$source)
return the length copied.
 [2003-11-17 22:36 UTC] sniper@php.net
Wez, please check this one out.

 [2004-09-20 12:36 UTC] wez@php.net
please try PHP 5.0.1 and let us know if this works
 [2004-09-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-06-18 14:40 UTC] okumurya at hotmail dot com
In PHP 4.4.2, I also encounter this ploblem.

I will store data as follows:
 00000000  ff d8 ff e0 00 10 4a 46  49 46 00 01 02 00 00 64  |......JFIF.....d|
 00000010  00 64 00 00 ff fe 00 12  41 64 6f 62 65 20 49 6d  |.d......Adobe Im|
 00000020  61 67 65 52 65 61 64 79  ff ec 00 11 44 75 63 6b  |ageReady....Duck|
 .
 .
 .


But, PHP really stores data as follows:
 00000000  00 00 10 00 4a 00 46 00  49 00 46 00 00 00 01 00  |....J.F.I.F.....|
 00000010  02 00 00 00 00 00 64 00  00 00 64 00 00 00 00 00  |......d...d.....|
 00000020  00 00 12 00 41 00 64 00  6f 00 62 00 65 00 20 00  |....A.d.o.b.e. .|
 .
 .
 .



May I reopen this issue?
Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 22:01:28 2024 UTC