tags:

views:

125

answers:

1

Can anyone provide syntax to create a table trigger preferably with DBI's do() method. It doesn't seem to like me putting everything on one line. Not sure what i'm doing wrong. Here's what I've got:

$dbh->do("CREATE TABLE image(img_id integer primary key, md5sum text, path text, name text, date DATE)");
$dbh->do("CREATE TRIGGER insert_img_date AFTER  INSERT ON image BEGIN UPDATE image SET date = DATETIME('NOW') END");
+5  A: 

Your second SQL statement is not valid syntax even if you try it from console.
Here's the same one with some fixes(now it works):

CREATE TRIGGER insert_img_date AFTER  INSERT ON image BEGIN UPDATE image SET date = DATETIME('NOW'); END ;
xxxxxxx
Man that was dumb. Thank you very much.
vicTROLLA
The only dumb question is the one you didn't ask and chose to suffer in silence instead...
Chris Huang-Leaver