search() without search criteria

[prev] [thread] [next] [Date index for 2005/04/29]

From: Will Hawes
Subject: search() without search criteria
Date: 12:36 on 29 Apr 2005
I need to implement paging for potentially large result sets using CDBI.=
 The pager should be usable for any CDBI subclass, so column names will =
not be known beforehand. Search criteria are optional. In order to keep =
things as efficient as possible I would like to make sure that only the =
number of records required for a single page will be returned by the que=
ry, so I would like to use search() and pass attributes e.g. "rows", "of=
fset", etc as the second argument.

This works fine when search criteria are specified:

$class->search(column1 =3D> value, {rows =3D> 10});

When there are no search criteria specified however:

$class->search({}, {rows =3D> 10});

search() tries to execute a query like this:

"SELECT <columns> FROM <table> WHERE"

which fails, because there is nothing after WHERE.

I'm aware there are probably workarounds - using retrieve=5Fall() to ret=
urn an iterator is one that springs to mind, a custom constructor is ano=
ther - but I want to avoid returning whole result sets into memory or, w=
orse, writing custom SQL.

I'd like to hear opinions regarding a patch to Class::DBI so that search=
() accepts an empty hash as the first argument. This would allow order=
=5Fby, limit, etc to be applied to the whole result set rather than havi=
ng to use search criteria too.

All feedback gratefully received.

Regards

WH

(message missing)

search() without search criteria
Will Hawes 12:36 on 29 Apr 2005

Re: search() without search criteria
Matt S Trout 13:18 on 29 Apr 2005

Re: search() without search criteria
Daniel Wijnands 14:06 on 29 Apr 2005

Re: search() without search criteria
Perrin Harkins 14:25 on 29 Apr 2005

Re: search() without search criteria
Will Hawes 16:53 on 29 Apr 2005

Re: search() without search criteria
Tony Bowden 18:38 on 29 Apr 2005

Re: search() without search criteria
Matt S Trout 19:38 on 29 Apr 2005

Re: search() without search criteria
Will Hawes 20:19 on 29 Apr 2005

Re: search() without search criteria
Tony Bowden 22:48 on 29 Apr 2005

Re: search() without search criteria
Perrin Harkins 16:40 on 30 Apr 2005

Re: search() without search criteria
David Baird 14:31 on 29 Apr 2005

Re: search() without search criteria
Peter Speltz 19:11 on 29 Apr 2005

Re: search() without search criteria
Tony Bowden 22:52 on 29 Apr 2005

Re: search() without search criteria
Will Hawes 12:13 on 30 Apr 2005

Re: search() without search criteria
Tony Bowden 12:19 on 30 Apr 2005

Re: search() without search criteria
merlyn (Randal L. Schwartz) 15:44 on 30 Apr 2005

Re: search() without search criteria
Will Hawes 17:45 on 30 Apr 2005

Re: search() without search criteria
Tony Bowden 10:27 on 01 May 2005

Re: search() without search criteria
Will Hawes 14:13 on 01 May 2005

Generated at 10:24 on 04 May 2005 by mariachi v0.52