On Tue, Dec 11, 2007 at 11:11:05AM +0200, Angel Kolev wrote:
> Hi guys.
> How i can check if my $rs = 
> $c->model('AppModelDB::Clients')->search({id=>$id}); succeed ?

If you're looking up by PK why not just use find() ?

> If i try "myErrorFunc() unless defined $rs->first->id" (or something 

if (my $client = $c->model('AppModelDB::Clients')->find({ id => $id })) {
  ... do stuff ...
} else {
  $self->handle_error;
}

Notes:

You're writing in an OO system, use methods not functions.

You're writing perl, use names_like_this not namesLikeJava.

If you actually -do- want an rs then if (defined $rs->first) or if ($rs->count)
are sufficient.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
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