[Dbix-class] Query problem

Patrick Meidl patrick at pantheon.at
Mon May 14 20:12:36 GMT 2012


On Mon, May 14 2012, Kenneth S Mclane <ksmclane at us.ibm.com> wrote:

> Yes, the helper looked very promising, but there is little to no
> documentation as to what and how it does it's thing. I tried getting
> it to work but to no avail as there is no indication of how to deal
> with multiple things. It's example, (and I find this endemic in DBIx
> docs) refers to a scalar "$schema" with no explanation as to what this
> contains or what it should be set to. Can I substitute
> "$c->model('xxx::yyy') syntax for my code?

have a look at

https://metacpan.org/module/Catalyst::Model::DBIC::Schema

which explains in the synopsis how to translate plain DBIx::Class
notation into Catalyst model calls.

in your example, $c->model('ORANGES::Account') is a shortcut for
$c->model('ORANGES')->resultset('Account'), which is again short for
$c->model('ORANGES')->schema->resultset('Account'). when the DBIc docs
refer to $schema, it means $c->model('ORANGES')->schema in your case.

IMHO, the DBIx::Class docs are excellent, I think the frustration of a
newcomer is mainly caused by the amount of information that's there, so
you will have to climb a fairly steep learning curve. I started with

https://metacpan.org/module/DBIx::Class::Manual

to get an overview, and now mostly use the pod in these modules for
reference:

https://metacpan.org/module/DBIx::Class::Schema
https://metacpan.org/module/DBIx::Class::Relationship
https://metacpan.org/module/DBIx::Class::ResultSet

as somebody else already pointed out, it can be more difficult to get
started with DBIc when you try to translate literal SQL queries into
DBIx::Class queries, rather than thinking about your data on the
abstract level which DBIc provides and trying to build your queries
using its idioms.

HTH

    patrick

-- 
Patrick Meidl ........................ +43 1 9688226 (home)
Pazmanitengasse 4/10 ................. +43 680 2072780 (mobile)
1020 Wien ............................ patrick at pantheon.at
Austria .............................. http://pmeidl.homelinux.net/
--




More information about the DBIx-Class mailing list