I have been fighting with this for days now. Can't seem to get to the bottom of it. I have a Sybase table that has a long binary field which contains a jpg. I am pulling the pictures from the table using this query. PHP.ini file has memory_limit = 4096M
SELECT TOP 1 base64_encode(ImageData) as img, IL.Description As alt
FROM ProductImage PI
JOIN ImageLibrary IL
ON PI.ImageId = IL.ImageId
WHERE PI.ProductCode = '3894'
ORDER BY PI.ImageOrder
If I select the length of the imagedata as below:
SELECT length(ImageData) as img, IL.Description As alt
FROM ProductImage PI
JOIN ImageLibrary IL
ON PI.ImageId = IL.ImageId
WHERE PI.ProductCode = '3894'
ORDER BY PI.ImageOrder
This returns 38924
However when I run the query in php and loop over the result I only get 4096 as the length.
<?php
/// GET THE IMAGE FROM IMAGE LIBRARY
$conn = odbc_connect($connect_string,'','');
$Image='';
$Alt ='';
$query='';
$query = "SELECT TOP 1 base64_encode(ImageData) as img, IL.Description As alt";
$query .= " FROM ProductImage PI";
$query .= " JOIN ImageLibrary IL ";
$query .= " ON PI.ImageId = IL.ImageId";
$query .= " WHERE PI.ProductCode = '3894'";
$query .= " ORDER BY PI.ImageOrder";
//var_dump ($query);
$res = odbc_exec($conn,$query)or die("Whoops! I could not run this query " . $query);
$num_rows = odbc_num_rows($res) & 0xffffffff;
$rows = array();
while (odbc_fetch_row($res)) {
$len = strlen(odbc_result($res,"img"));
If ($len > 0){
$image = odbc_result($res,"img");
$alt = odbc_result($res,'alt');
} else {
$image='No Image binary goes here'
$alt = 'No Image saved sorry';
}
}
?>