* Re: how to specify current timestamps in a ->search operation in DBIx::Class?

2 messages Options
Embed this post
Permalink
kakimoto

* Re: how to specify current timestamps in a ->search operation in DBIx::Class?

Reply Threaded More More options
Print post
Permalink
hello, Tom!
 found the syntax!

Something like this, " ->search({'created_time' => { '>=', '2006-06-01
00:00:00' } })" has worked well for me!

by the way, there is something wrong with the mailing list because I
can;t get any replies. I had to manually check the searchable archive .


Can some admins please help?

thanks

k. akimoto




[Dbix-class] Re: how to specify current timestamps in a ->search
operation in DBIx::Class?

Tom Hukins
Thu, 25 Jun 2009 01:32:51 -0700

On Thu, Jun 25, 2009 at 02:04:24PM +1000, [hidden email] wrote:
> I have looked through SQL::Abstract and well, got stuck as I don't know
> how to specify "NOW()".
>
> My question is, how do we do current time comparisons in DBIx::Class'
> where clause filter for a DBIx::Class->search call please? :)

The examples in the FAQ should help:
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Manual/FAQ.pod#Searching

If they don't, let us know how to improve them to make this easier to
understand.

Tom

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive:
http://www.grokbase.com/group/dbix-class@...



_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Tom Hukins

Re: * Re: how to specify current timestamps in a ->search operation in DBIx::Class?

Reply Threaded More More options
Print post
Permalink
On Thu, Jun 25, 2009 at 08:13:07PM +1000, [hidden email] wrote:
> Something like this, " ->search({'created_time' => { '>=', '2006-06-01
> 00:00:00' } })" has worked well for me!

But in your original question you asked:

> > I have looked through SQL::Abstract and well, got stuck as I don't know
> > how to specify "NOW()".

If you trace the search() query with 'created_time' you wrote above,
you'll see it includes "2006-06-01 00:00:00" in the SQL, not "NOW()":
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Manual/Troubleshooting.pod#Tracing_SQL

You want to pass search() a scalar reference to the string 'NOW()' as
described in the first link I sent.

Tom

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...