Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Re: [Dbix-class] class mapping

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


bobtfish at bobtfish

Mar 14, 2012, 3:19 AM

Post #1 of 1 (150 views)
Permalink
Re: [Dbix-class] class mapping

> On 13 March 2012 16:33, Sung Gong <sung [at] bio> 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"?

Yes.

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)

Yes.

->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?

Yes.

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

Cheers
t0m



_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.