Re: Class::DBI::Plugin
[prev]
[thread]
[next]
[Date index for 2004/06/30]
On Jun 30, 2004, at 6:17 PM, Addison, Mark wrote:
> Looks good :) The only thing I find a bit odd is using a constant for
> the SQL. Why did you do it this way? Why not just use a
> Class::DBI::Plugin::set_sql that delegates to the class your plugged
> into? hmmmm its a complile time thing isn't it...
Yes indeed. If we take this approach, I would suggest
__PACKAGE__->init_plugin( ... );
> Or maybe an init_plugin method. Could also be usefull if the plugin=20=
> wants
> to add class data, TEMP columns etc.
> e.g.
>
> =A0sub init_plugin {
> =A0=A0=A0=A0 my $class =3D shift;=A0 # Class your plugged into
> =A0=A0=A0=A0 $class->set_sql( count_search_where =3D> "..." );
> =A0=A0=A0=A0 $class->mk_classdata('_plugin_search_where_foo');
> =A0}
>
> (Apologies if this was covered in the 'abstract search count' thread)
It wasn't. :-)
I thought using a constant was not bad, as it ends up as a subroutine,=20=
and I am looking for subroutines anyway from the base class. You can=20
also conveniently put in more SQL statements at once:
use constant SQL =3D> ( name1 =3D> $sql1, name2 =3D> $sql2, ... );
I have to admit that I never used TEMP columns so far, but I suggest a=20=
similar mechanism:
use constant TEMP =3D> ( ... );
--=20
J.-C Zeus (mail@xxxxxx.xxx)