Pardon me, I am not a strong Perl programmer. If I want to check for a
unique username before submitting, I would do something like the
following? (Please pardon my Catalyst format. It's all I know.)
if ($result->model('DB::Account')->find({username=>$submitted_username}) {
# Then it is a duplicate.
# Return an error
} elseif {
# Not a duplicate, go ahead and submit it.
}
I'm not familair with die + eval. My concern is that I would need to
do this for every column that is supposed to be unique. This means I
would need to make a call for each one?
Rob Kinyon wrote:
On Thu, Jun 4, 2009 at 10:29, Ascii King <[email protected]> wrote:
Thanks for the help. One more question, though. The preferred method for
handling unique columns is to let the database manage them and then just
trap the error message using Exception::Class?
Using your favorite exception handling method, yes. I personally don't
like Exception::Class, but others do. I like die + eval - simple and
clean.
_______________________________________________
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]