Class::DBI and stalinesque hiding of THE TRUTH
Aaron Trevena
aaron.trevena at gmail.com
Fri Jun 23 10:49:21 BST 2006
On 23/06/06, Stig Brautaset <stig at brautaset.org> wrote:
>
> On 23 Jun 2006, at 10:10, Simon Wistow wrote:
> > Is there a clever way I can do this using cunning trickery? Possibly
> > views or something. My DB skills are, at present, as weak as a
> > kitten on
> > Ludes who's also in traction and wasn't particularly strong in the
> > first
> > place and used to get sand kicked in its face by other, larger kittens
> > when down at the kitten beach.
> >
> > I eagerly await the fruits of your exceptional cleverity.
>
> How could I resist such flattery?
>
> We have something like this, where 'user_view' is a view of the
> 'user_table' which only has active users:
>
> package RawUser;
> use base 'Class::DBI';
> __PACKAGE__->table('user_table');
> 1;
>
>
> package User;
> use base 'RawUser';
> __PACKAGE__->table('user_view');
> 1;
>
>
> I don't know if MySQL allows this though; we're using Pg.
Nope. No views in MySQL, at least not 3 and 4, which is what most
people are using.
But splitting into two classes and over-riding the sql for
retrieve/search via set_sql should do the trick just fine.
A.
More information about the london.pm
mailing list