CURRENT_TIMESTAMP for MySQL in Perl DBI
Posted by: jerrykrinock
Posted on: 2006-07-11 12:47:00
OK, I think that VALUES(,,,) is neat and safe from SQL Injection. Now, I want to INSERT a record with a timestamp:
$query = q{
INSERT INTO rejectedTrades
values (?, ?, ?) } ;
$statementHandle = $databaseHandle->prepare($query) ;
# error handling omitted
my $didExecute = $statementHandle->execute(NULL, CURRENT_TIMESTAMP, $serialNumberReceived) ;
Everything works except the CURRENT_TIMESTAMP. I have also tried in the above line: CURRENT_TIMESTAMP(), NULL, and DEFAULT (with the column's DEFAULT set to CURRENT_TIMESTAMP).
Result: I get either an error or 0000-00-00 00:00:00.
Is there a trick to getting a CURRENT_TIMESTAMP via DBI? It works fine if I INSERT from the command line.
Thanks again,
Jerry