freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Franck Martin <Franck AT sopac.org>
- To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
- Subject: Image field in SQL 7.0
- Date: Mon, 10 Sep 2001 15:56:50 +1200
I'm trying to deal with SQL 7.0 image fields using freetds and php...
I had it working with old freetds and php 3.0 but now some images display
and some don't and I have no clue....
How to handle images with freetds and php any ideas?
I was using the following code as a procedure:
CREATE PROCEDURE Snap_Image2vchar
@Snap_ID int
AS
DECLARE @Count int
DECLARE @Start int
DECLARE @NextLen int
SELECT @Count = datalength(Snap) FROM SnapShot WHERE
Snap_ID=@Snap_ID
SELECT @NextLen = 4096
SELECT @Start =1
CREATE TABLE #T (Snap text)
WHILE (@Count > 0)
BEGIN
if (select @Count) < @NextLen
begin
select @NextLen = @Count
end
insert into #T select
convert(text(4096),convert(varchar(4096),substring(Snap,@Start,@NextLen)))
as Snap from SnapShot where Snap_ID = @Snap_ID
select @Count = @Count - @NextLen
select @Start = @Start + @NextLen
END
SELECT * FROM #T
DROP TABLE #T
------------
<%
Header("Content-type: image/jpeg");
$conn = sybase_pconnect("host","login","password");
$ok=sybase_select_db("DB",$conn);
if (@$snapid==0)
{
$snapid=1;
}
$result = sybase_query("Snap_Image2vchar ".$snapid);
$nbrows=sybase_num_rows($result);
for ($i = 0 ; $i < $nbrows; $i++)
{
sybase_data_seek($result,$i);
$par = sybase_fetch_object($result);
if ($i==0)
{
// Needs to remove the OLE header if any...
$pos=strpos($par->Snap,"JFIF");
echo (substr($par->Snap,$pos-6));
} else
{
echo ($par->Snap);
}
}
%>
Franck Martin
Network and Database Development Officer
SOPAC South Pacific Applied Geoscience Commission
Fiji
E-mail: franck AT sopac.org <mailto:franck AT sopac.org>
Web site: http://www.sopac.org/
<http://www.sopac.org/> Support FMaps: http://fmaps.sourceforge.net/
<http://fmaps.sourceforge.net/>
This e-mail is intended for its addresses only. Do not forward this e-mail
without approval. The views expressed in this e-mail may not be necessarily
the views of SOPAC.
- Image field in SQL 7.0, Franck Martin, 09/09/2001
Archive powered by MHonArc 2.6.24.