[CDBI] where clause in AbstractSearch

Rhesa Rozendaal perl at rhesa.com
Wed Dec 13 16:23:48 GMT 2006


rahed h wrote:
> Hello,
> 
> I can retrieve records from sqlite this way:
> select id,col1 from mytable where date(mydate) = date('now');
> 
> This will return records as of today.
> 
> With Class::DBI I tried:
> @records = Mymodule->search_where ('date(mydate)' => { '=', 
> "date('now')" });
> 
> but no records found. If I supply value as a string such as 2006-12-13, 
> it's ok.
> 
> What's the right syntax like?

Since CDBI::AbstractSearch uses SQL::Abstract, you can look at the 
documentation for the latter. You'll see that supplying a reference to a 
string will pass that string unaltered:

   search_where( q{date(mydate)} => \ q{ = date('now') } );

HTH,
Rhesa



More information about the ClassDBI mailing list