Using NOW() with MySQL
[prev]
[thread]
[next]
[Date index for 2004/08/05]
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
|