Gossamer Forum
Quote Reply
SQL syntax help
Seems it can not be implemented on GL 2.x
Can anyone point me the right syntax for this?


$dbh->do ("INSERT INTO Links (ID,date) VALUES(NULL,CURDATE( ))");
my $new_id = $dbh->{mysql_insertid};



Before you ask me "why 2.x instead 3.x?": My company did so many changes in the code that is impossible to upgrade.

I appreciate any help.

Sara

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Blondies can have brains (sometimes...)

Last edited by:

SaraBem: Mar 28, 2007, 1:21 PM
Quote Reply
Re: [SaraBem] SQL syntax help In reply to
Hi Sara,

I am not sure if you Links table required more input. If not, below should work. ID is usually the primary key and autoincrement.

$dbh->do ("INSERT INTO Links (date) VALUES(CURDATE( ))");

Cheers,



Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [SaraBem] SQL syntax help In reply to
Try something like:
Code:
my $sth = $DB->table('Links')->insert({ date => \'NOW()' });
my $id = $sth->insert_id();

Adrian