On Tue, 11 Mar 2003 23:14:08 +0000 mel awaisi <[EMAIL PROTECTED]> wrote:

> I am using stat to obtain image size and image date, however the format that 
> is coming especially for the date. the format seems wrong,
> 
> mysql> select * from imageinfo;
> +----------+--------------------+------------+---------------------+
> | image_id | image_name         | image_size | image_date          |
> +----------+--------------------+------------+---------------------+
> |        1 | 2003test.jpg       |        123 | 0000-00-00 00:00:00 |
> |        2 | 2003test.jpg       |     123000 | 2003-03-10 22:10:14 |
> |        3 | 2003test1.jpg      |     124000 | 2003-03-10 22:13:48 |
> |        4 | 20030311143242.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |        5 | 20030311143242.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |        6 | 20030311143242.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |        7 | 20030311143242.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |        8 | 20030311143243.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |        9 | 20030311143243.jpg | 1047393161 | 2000-10-47 39:31:62 |
> |       10 | 45677890           | 1047422331 | 2000-10-47 42:23:32 |
> |       11 | 123456789          | 1047422331 | 2000-10-47 42:23:32 |
> |       12 | 1111111111111111   | 1047422331 | 2000-10-47 42:23:32 |
> +----------+--------------------+------------+---------------------+
> 12 rows in set (0.01 sec)
> 
> my $file;
> my $size;
> my $mtime;
> 
> $file = "/home/me/images/2003_03_11_22_38_52.jpg";
> ($size, $mtime) = (stat ($file))[8,9];

Both $size and $mtime integers as defined in `perldoc -f stat`.
localtime(), gmttime(), and sprintf() may also be interesting to you,
but none of them are DBI specific.

> my $rows_affected = $dbh->do("INSERT INTO imageinfo 
> VALUES('null','1111111111111111',$size,$mtime)");

Unless mysql knows how to convert integer constants to it's date
format, there is no reason to expect this statement to work.

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to