Re: Re: DB / tablevalues / query 'now()'

From: Date: Mon, 20 Dec 2004 02:36:24 +0000
Subject: Re: Re: DB / tablevalues / query 'now()'
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16333@lists.php.net to get a copy of this message
On Sun, 19 Dec 2004 18:00:21 -0500, Daniel Convissor <danielc@analysisandsolutions.com> wrote: > > Matthew Weier O'Phinney wrote: > > >* Stephan Heller <heller@daik.de>: > > > > > >>I'm looking for a possibility to insert a datetime-Value comparable to > > >>'now()' in MySql > > >>using 'autoPrepare' and 'execute' > > >>Now() doesn't work by using this methods > > > > > >You can use NOW() when using simply prepare() and execute(): > > > $sth = $db->prepare('INSERT INTO table(ts) VALUES(!)'); > > > $res = $db->execute($sth, array('NOW()')); > > The best approach is putting the NOW() call in the prepared SQL statement > because it never changes and it's a function. Example: > > $sth = $db->prepare('INSERT INTO table (ch, ts) VALUES (?, NOW())'); > > Personally, I don't like autoPrepare(). Too much magic. I like SQL. > It's powerful. Use it. > > As far as abstracting the function used to obtain the present time, as > someone was asking about, that kind of stuff may come up in Version 2 of > DB. > But I thoughs MDB2 was going to become DB2...? -- Justin Patrin

« previous php.pear.general (#16333) next »