Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Answer: Placeholders and NOW()

by runrig (Abbot)
on Aug 15, 2002 at 02:36 UTC ( #190283=categorized answer: print w/replies, xml ) Need Help??

Q&A > database programming > Placeholders and NOW() - Answer contributed by runrig

yes:
sub NOW { # Return current time in whatever format it # Needs to be in } $sth->execute(NOW());
But I suspect NOW() is a function in your particular database, in which case you wouldn't use a placeholder, and you would just put a literal NOW() in your SQL statement.

Example:

my $sth = $dbh->prepare(q{ INSERT INTO t ( foo, bar, time ) VALUES (?, ?, NOW() ) }); $sth->execute($foo, $bar);

Replies are listed 'Best First'.
Re: Answer: Placeholders and NOW()
by dws (Chancellor) on Aug 15, 2002 at 02:48 UTC
    Instead of using a parameter that you'll bind at execute() time to the current time, include it instead directly in the query. For example, INSERT INTO t (msg, ts) VALUES(?, NOW())
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: But I guess I'll find out soonish, as my application seems to use Prima for more than just displaying the OpenGL output soonish ;))
[ambrus]: No, I think the timers are handled fine in the event loop, as far as I can see.
[Corion]: So far, I liked Prima quite well as it simply seems to do what I want even if it has an upside-down coordinate system. But it installs from CPAN out of the box and is cross-platform
[ambrus]: Corion: which coordinate system is the upside down one?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2016-12-09 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.