Using NOW() with MySQL

[prev] [thread] [next] [Date index for 2004/08/05]

From: tom
Subject: Using NOW() with MySQL
Date: 11:46 on 05 Aug 2004
Hi.

This seems like a terrible question to ask, but I have read through the FAQ, the perldoc, googled and have tried as many ways as I can find in any documentation to get Class::DBI to pass "NOW()" to MySQL as a column value that will make mySQL insert the current date.

SQL that I want: INSERT INTO note ('foreignKey', 'note', 'created')
                        VALUE (1, 'some note', NOW());

This is my current incarnation.

package My::Base;

use base 'Class::DBI';
Table::Homelet->connection( "string", "name", "pass" ); #paraphrased.

__PACKAGE__->set_sql(setAsNow => <<"");
UPDATE __TABLE__
SET %s = NOW()
WHERE __IDENTIFIER__
1;

package Note;
require My::Base;

Note->table('note');
Note->columns(All => qw/id, foreignKey, created, note/ );

my $newNote = My::Base->create(
                { foreignKeyId = 1,
                  note       => 'some note'
                } );
$newNote->sql_setAsNow("created");
1;


I have tried all sorts of variations, amazed that I could not just hadd the key-value pair created=>NOW() into the create hash.

Surely I am missing something very simple?

Thanks.

Using NOW() with MySQL
tom 11:46 on 05 Aug 2004

Re: Using NOW() with MySQL
karjala_lists 11:55 on 05 Aug 2004

Re: Using NOW() with MySQL
karjala_lists 12:15 on 05 Aug 2004

Re: Using NOW() with MySQL
Tony Bowden 12:02 on 05 Aug 2004

Re: Re: Using NOW() with MySQL
tom 16:04 on 06 Aug 2004

Re: Re: Using NOW() with MySQL
Tony Bowden 16:26 on 06 Aug 2004

Re: Re: Using NOW() with MySQL
Tim Bunce 16:30 on 06 Aug 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52