[Dbix-class] What should DBIC objects stringify to?

Florian Ragwitz rafl at debian.org
Wed May 3 16:49:22 CEST 2006


On Wed, May 03, 2006 at 02:06:30PM +0200, Matija Grabnar wrote:
> While programming in CDBI I got used to this paradigm:
> $obj = $something->search({whatever});
> if ($obj) {
>     # do something with the result
> } else {
>     # we got an empty result
> }

You may use

  $obj = $something->single({whatever});
  if ($obj) {
      # do something with the result
  } else {
      # we got an empty result
  }

if you expect that {whatever} will give only one object back.


-Flo

-- 
BOFH excuse #96:
Vendor no longer supports the product
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060503/22943d6b/attachment.pgp 


More information about the Dbix-class mailing list