On May 29, 2009, at 2:43 PM, Jarom Smith wrote:
One revelation I had recently which I don't think has been mentioned anywhere (at least not that I recall) is that when using DBIC and Catalyst, *everything* is treated as a scalar. (is this a true statement?) So in other words,

my $people = $c->model('AddressDB::People')

instead of

my @people = $c->model('AddressDB::People')


Assuming that AddressDB::People is a DBIx::Class-based model, then

my $people = $c->model('AddressDB::People')

will get you a DBIx::Class::ResultSet object, which is an object. You can then use that object to iterate over the resultset or chain another search on it.

my @people = $c->model('AddressDB::People')

will get you an array of row objects, which are the values returned by iterating over the resultset. It's the equivalent of $c- >model('AddressBookDB::People')->all();

Catalyst just provides a thin wrapper around the model, so this doesn't really have anything to do with Catalyst and is more the behaviour of DBIx::Class.
        - john romkey
        http://www.romkey.com/


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

Reply via email to