[Dbix-class] What should DBIC objects stringify to?
Alan Humphrey
alan.humphrey at comcast.net
Wed May 3 16:51:19 CEST 2006
Perhaps:
$obj = $schema->('Table')->find({whatever})->first;
if ( $obj ) {
} else {
}
is what you're looking for?
-----Original Message-----
From: dbix-class-bounces at lists.rawmode.org
[mailto:dbix-class-bounces at lists.rawmode.org] On Behalf Of Matija Grabnar
Sent: Wednesday, May 03, 2006 5:07 AM
To: dbix-class at lists.rawmode.org
Subject: [Dbix-class] What should DBIC objects stringify to?
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
}
In other words, in CDBI results stringify (if that's the wrong word,
please enlighten me) into undef (or some other false value) if they
don't contain any elements, and to the primary key otherwise.
I understand that this is somewhat trickier with DBIC, considering DBIC
objects can easily have multiple primary keys.
But could we still have something resolving to a false value when a
search returns
nothing? Or am I missing something in the docs?
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
More information about the Dbix-class
mailing list