[Dbix-class] result testing
Ronald J Kimball
rkimball+dbixclass at pangeamedia.com
Tue Dec 11 14:36:43 GMT 2007
The call to $rs->first returns undef, so you're trying to call
undef->id. That's why you get the error. Is that enough of a hint? :)
Try this:
myErrorFunc() unless $rs->first;
If id is a primary or unique key, you could do this instead:
myErrorFunc() unless $c->model('AppModelDB::Clients')->find({id=>$id});
Ronald
Angel Kolev wrote:
> Hi guys.
> How i can check if my $rs =
> $c->model('AppModelDB::Clients')->search({id=>$id}); succeed ?
>
> If i try "myErrorFunc() unless defined $rs->first->id" (or something
> like this) the result is always "Caught exception in......... Cant call
> method "id" on undefined value.....". I just wanna know if that ID
> exists in my DB and throw Error screen if not.
> Thanks
>
More information about the DBIx-Class
mailing list