Re: Feature request - Allow searching columns of related tables in search() and search_like()

[prev] [thread] [next] [Date index for 2005/01/10]

From: Lance A. Brown
Subject: Re: Feature request - Allow searching columns of related tables in search() and search_like()
Date: 13:59 on 10 Jan 2005
Will Hawes wrote:
> SELECT * FROM orders, addresses, orderproducts WHERE orders.address =
> addresses.id AND orderproducts.order = orders.id AND orders.date =
> '2005-01-10' AND addresses.town = 'London' AND orderproducts.productname
> = 'foo'

Sounds like a perfect opportunity for 'set_sql':

OrdersPackage->set_sql(report => qq{
   SELECT orders.* FROM orders, addresses, orderproducts WHERE
orders.address = addresses.id AND orderproducts.order = orders.id AND
orders.date = ? AND addresses.town = ? AND orderproducts.productname = ?
  });

my $orders = OrdersPackage->search_report('2005-01-10', 'London', 'foo');

will give you an OrdersPackage iterator containing each object that
matches your select query.  I wrote this off the top of my head so it my
have typos, but the idea is there.

--[Lance]

        -- 
         Celebrate The Circle   http://www.celebratethecircle.org/
 Carolina Spirit Quest  http://www.carolinaspiritquest.org/
 My LiveJournal  http://www.livejournal.com/users/labrown/
 GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9
 CACert.org Assurer

(message missing)

Re: Feature request - Allow searching columns of related tables in search() and search_like()
Lance A. Brown 13:59 on 10 Jan 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52