Why not use a grep on the results from find?

 -- John

On Sep 8, 2008, at 9:29 AM, Dermot <[EMAIL PROTECTED]> 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.

or a submission like this

my $rs = $c->model('MyApp::Files')->find({'sub_id' => $id})

However, each submission can have up to 8 different file types (jpg,
txt,...). Say I want to know if a submission has a  jpeg in it. I
could loop through the resultset and search for /jpg$/ but I suspect
that not how a pro would do it. I suspect the answer would be to 1)
Store the type as a ENUM field (not SQLite) or 2) use some additional
criteria for the find query or  3) use search instead.

Any tips/thoghts?
TIA,
Dp.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to