[Dbix-class] To find or search?

Zbigniew Lukasiak zzbbyy at gmail.com
Tue Sep 9 09:29:57 BST 2008


On Mon, Sep 8, 2008 at 3:29 PM, Dermot <paikkos at googlemail.com> wrote:
> Hi,
>
> I think this is a bit of a lame question but I'll ask anyway.
>
> I have a (SQLite3) table of files. There are 4 fields as set out below.
>
> id INTEGER PRIMARY KEY,
> sub_id INTEGER,
> users_id INTEGER,
> path VARCHAR(50) UNIQUE ON CONFLICT IGNORE
>
> I have set-up beongs_to relationships between tb.files and tb.subs and
> tb.users. All is well and I can recall the list of files belonging to
> a user like this
>
> my $rs = $c->model('MyApp::Files')->find({'users_id' => $id}) # Yes
> it's a Cat app.

There is something confused here.  ->find does not return a list (nor
a resultset - as one could infere from your naming convention).
->find returns a DBIx::Class::Row object - just one.  See
http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/ResultSet.pm#find

If you want a list - then user search.

Cheers,
Zbigniew
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/



More information about the DBIx-Class mailing list