[Dbix-class] Use of ->resultset mandatory?

Ash Berlin ash at cpan.org
Mon Oct 30 21:12:57 GMT 2006


Mike Friedman wrote:
> Greetings,
> 
> I'm used to Class::DBI and very new to DBIx::Class.
> 
>  >From the docs, it seems like to execute any search, I have to
> 
> 1. Instantiate a schema object and connect it

Yes. Call it once and keep hold of it.

> 2. Call $schema->resultset('MyTableClass')->search( ... );

Yup, you have to do that every time.
> 
> In Class::DBI, since the table classes generally inherit from the main 
> DB class, I can just call MyTableClass->search( ... ) which seems a lot 
> simpler. (And less to type.)

It does however tie you to one and only one database connection. With 
DBIx::Class you can use different DBI connections for the same tables/schema
> 
> Is there a similar way to achieve this simpler syntax with DBIx::Class, 
> or do I have to use $schema->resultset every time?
> Is there a recommended way to encapsulate connection parameters, so I 
> don't have to call $schema->connect all over the place?
> 
> (Note: I'm not trying to be obnoxious, I just don't really quite 
> understand how DBIC is organized just yet.)
> 
> 
> Thanks,
> 
> Mike
> 




More information about the DBIx-Class mailing list