[Dbix-class] getting a connection in a static method with no args ...

Daniel McBrearty danielmcbrearty at gmail.com
Sun Aug 13 15:42:15 CEST 2006


well, the long story is I have a number of places on my schema where i
want tt write some custom methods :

{
  my $cache = undef;
    sub get_some_common_stuff{
      unless ($cache){
      #init $cache
  }
return $cache->{something};
}
}

and init cache is what needs the handle. So is what your saying that
all these should be in MySchema.pm? I think I prefer have them against
the actual tables they naturally belong with (e.g.
MySchema::Languages.pm is a more natural place to have
get_original_language() .... )


On 8/13/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> Daniel McBrearty wrote:
> > i'm actually using "MySchema->connection($dsn)"
> >
> > then MySchema->resultset( ... )
> >
> > but i seem to remember someone telling someone they oughtn't ....
>
> Weeeel ... I'm not amazingly fond of that usage but it works by design, not by
> accident and it isn't going away. It may cause you all sorts of fun if you
> ever need multiple connections at once.
>
> Why not just make it a method on the schema so you call
>
> $schema->methodname
>
> and then that can access the schema as $self ?
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131



More information about the Dbix-class mailing list