logo       

Re: idiomatic way to handle manager class search results?: msg#00082

lang.perl.modules.dbi.rose-db-object

Subject: Re: idiomatic way to handle manager class search results?

On 6/29/06, Jonathan Vanasco <jon-GYD5gbT+W3w@xxxxxxxxxxxxxxxx> wrote:
> this works, just checking to see if its the idiomatic way-- as the
> docs didn't point to it...
>
> basically:
> a query in a manager for non-key fields...
> results are stuffed into $results
> check scalar @$ to see if there are results
>
> i *think* @$results is the right way to handle it. $results is a
> rosedb object, but overloads make it seem like an arrayref
> [...]
> my $results= $class->get_item(

If get_item() is a wrapper around get_objects(), then $results is a
reference to an array (or undef if your ->meta->error_mode is not set
to something that causes an exception to be thrown), not an RDBO
object. To check for any items in that array, yes, $@results will
work.

If you just want to see if any results exist, you can limit your query
to 1 item to keep it from fetching many of them: limit => 1. You can
also use get_objects_count() (or the auto-generated wrapper around it)
to just return a number of items. Finally, you can use
get_objects_sql() and then manually wrap the generated SQL in
something db-specific (e.g., some sort of EXISTS query) and then run
that using plain old DBI.

Which is "best" depends on your data and your db.

-John

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise