No, the faxes aren't 4GB. Most of the faxes are less than 50KB,
although they can be as large as a few MB. 4GB is a ridiculous amount
of memory to try to allocate for this. 4GB is the max that 32bit
versions of Windows can see. Is something causing the memory allocation
to loop until it reaches this maximum value?
When I execute the same SQL in the MS SQL management studio interface, I
get the expected resultset.
When I change the where clause portion in the prepared statement from
"WHERE id = :id AND attid = :attid" to contain "WHERE id =
119085977300014 AND attid = 0" and comment out my bindValue() lines, I
get the exact same memory allocation error in my PHP script.
I have isolated the problem to the query against the attdata column. If
I remove the attdata column from the query, the query executes just
fine. It may be worth noting this is an 'image' type column.
Could this be some bug in the way PHP, PDO, ODBC, and/or MS SQL are
communicating? Maybe 'image' columns aren't being handled correctly?
I'm fairly certain my code is correct. I appreciate all of your comments.
Has anyone even tried querying an 'image' type column out of MS SQL 2005
using PDO ODBC?
Regards,
Carlton Whitehead
Jeffery Fernandez wrote:
On Thursday 27 September 2007 04:21, Carlton Whitehead wrote:
Hi everyone,
I'm working on a script that downloads archived fax images (TIFFs and PDFs)
from a MS SQL Server using the PDO ODBC driver. I get the below error
regardless of which fax I try to get from the database. Each fax is a
different size, and both of the memory allocation numbers are always the
same:
Fatal error: Out of memory (allocated 262144) (tried to allocate 4294967295
bytes) in C:\Inetpub\wwwroot\FMarchive\library\faxInbound.php on line 81
Ho big are those faxes? 4294967295 bytes = 4GB
have you tried executing that SQL directly into the database? Does it return
the right results?
The above error happened when querying a fax with a size of 17723 bytes.
According to my phpinfo(); page, the memory_limit is 128MB.
My machine has the below specs:
Windows Server 2003 SP2
IIS 6
2GB RAM
Microsoft SQL Server 2005 SP2
PHP 5.2.4
Here is the excerpt from my code:
public function downloadFax($id, $attid, $attsize)
{
try
{
$stmt = 'SELECT filename, attdata FROM fm_faxin_att WHERE id = :id AND
attid = :attid'; $pstmt = $this->db->prepare($stmt);
$pstmt->bindValue(':id', $id);
$pstmt->bindValue(':attid', $attid);
$pstmt->execute(); // this is the Line 81 referenced by the error
message $pstmt->bindColumn('filename', $filename, PDO::PARAM_STR);
$pstmt->bindColumn('attdata', $data, PDO::PARAM_LOB);
$pstmt->fetch(PDO::FETCH_BOUND);
return array('attdata' => $data, 'filename' => $filename);
}
catch (PDOException $e)
{
die($e->getMessage());
}
}
Any ideas?
Regards,
Carlton Whitehead
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php