RE: var_dump and sizeof database entry?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would do one of two things here:

1. add a size column to the db and have the image size added when inserting the image

2. run a trash script (either sql if your version support subselects or a little page) to get the size of
    the image and enter it into the size field

Another option is to use

select *, (length(image_fiedl)/1024) as Kb from table [where clause] to get the size

Bastien


From: Jordan Miller <jmil@xxxxxxxxxxxxxxxxxx>
To: PHP DB <php-db@xxxxxxxxxxxxx>
Subject:  var_dump and sizeof database entry?
Date: Thu, 5 Jan 2006 16:19:43 -0600

Hello,

This is stumping me something awful. I have searched the archive of this mailing list and google and the php and mysql websites with everything i can think of.

I have a simple mysql table with some basic columns and a blob column that holds an image file. What I need to get is the size of this image file for use with an rss feed (the enclosure "length" parameter).

In the simplest case, I thought I would just read the entire blob into a variable, and then I would be able to get the size of this variable. However, php does not seem to have a function to do this. Inexplicably, the "var_dump" command will actually dump the information I want, but it is very memory inefficient, because I get something like:
["preview"]=> string(17888) "ENTIRE CONTENTS OF BLOB HERE"

where all I really want is the 17888 value (for a 17.5 KB file).

What I was wondering is if there is a simple way to get this information from mysql directly without having to 1) select the blob column and 2) do a var_dump with output buffering and parsing for the parenthetical file size, which seems very inefficient to me.

any insight is greatly appreciated.

Jordan

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux