[Dbix-class] More funky sql

Matt S Trout dbix-class at trout.me.uk
Tue Jan 17 01:28:03 CET 2006


On Mon, Jan 16, 2006 at 05:46:48PM -0600, Brandon Black wrote:
> On 1/16/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > On Mon, Jan 16, 2006 at 04:11:49PM -0600, Brandon Black wrote:
> > > DISTINCT/COUNT stuff
> > >
> > There is, however, absolutely nothing to stop you doing
> >
> > $source->resultset->search(...,
> >   { select => [ { distinct => [ $source->columns ] } ],
> >     as => [ $source->columns ] });
> >
> 
> Ok, I see I have to up my game here to stump you.  How about Stored Procedures?
> 
> SELECT * FROM some_stored_func(x, y, z) me WHERE me = 42;
> 
> I have a few of these.  Should there be a class for each func which is
> a special type of table/source?  If that abstraction mostly worked, I
> guess there would have to be a func_args attribute to supply (x, y, z)
> in addition to the normal where clause and all...

->search(\%where, { select => [ '*' ], as => [ ... ],
           from => 'some_stored_func(?, ?, ?)', bind => [ $x, $y, $z ] });

Better still you could create a normal ResultSource object rather than the
table and set the 'from' attr on it (a Table is basically just a ResultSource
where ->from returns the name :)

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list