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

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

From: Tony Bowden
Subject: Re: Feature request - Allow searching columns of related tables in search() and search_like()
Date: 17:48 on 10 Jan 2005
On Mon, Jan 10, 2005 at 08:59:38AM -0500, Lance A. Brown wrote:
> 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 = ?
>   });

Except you don't need to do it like that.

As Will has pointed out, CDBI already knows lots of this.

You could do:

Order->set_sql(oap => q{
	SELECT __ESSENTIAL(o)__
    FROM __TABLE(=o)__, __TABLE(Address=a)__, __TABLE(Product=p)__
   WHERE JOIN(o a p)
     AND %s
})

and then do your substitution in the same was as search() normally
works, except you can prefix your columns with whatever abbreviations
you've used for the tables.

This could indeed be abstracted further. It's mostly a matter of syntax.

You need some way to specify what Classes you want to join, and what
abbreviations, if any, you wish to use for each (it would probably
default to the moniker).

Tony

(message missing)

Re: Feature request - Allow searching columns of related tables in search() and search_like()
Tony Bowden 17:48 on 10 Jan 2005

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