[Catalyst] Re: [Dbix-class] class mapping

Tomas Doran bobtfish at bobtfish.net
Wed Mar 14 10:19:02 GMT 2012

> On 13 March 2012 16:33, Sung Gong <sung at bio.cc> wrote:
>> Hi
>> I have a simple User table (mysql back-end) which is mapped into a
>> resultsource class User.pm. statically generated by the helper.
>> Just wondering any difference between
>> "MyApp::Schema::DB::Result::User" and "MyApp::Model::DB::User"?


The ::Result:: class represents a specific database row.

The MyApp::Model::DB::User class is a tiny wrapper around MyApp::Schema::DB::ResultSet::User, which represents a query (i.e. a set of results)

>> Both ref($c->model("DB::User")->find(1)) and
>> ref($c->model("NECTAR::User")->new_result({})) return
>> MyApp::Model::DB::User.
>> Is this normally what I expect? (or MyApp::Schema::DB::Result::User)


->find on a ResultSet will return a Result

->new_result on a ResultSet will return a Result.

>> One more question re the method 'new_result' of DBIx::Class::ResultSet:
>> I found $c->model("DB::User")->new_result({})->result_source->schema->storage
>> returns undef, whereas
>> $c->model("DB::User")->find(1)->result_source->schema->storage doesn't
>> (it shows DBIx::Class::Storage::DBI::mysql=HASH(0x1f21fdc0)).
>> Is this also sane?


Rows which aren't stored yet don't have storage.


More information about the Catalyst mailing list