X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=71595e3ac386f7604a63147c2b54b1e313ae821d;hb=2268474f6427676f69515a0ea47d638eaa6b497c;hp=31abf0120b95bc88d19f8a4e8b034589bd837a02;hpb=16667b3ab96a1c4a533d071e8e52eed883724828;p=dbsrgits%2FDBIx-Class.git
diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm
index 31abf01..71595e3 100644
--- a/lib/DBIx/Class/ResultSet.pm
+++ b/lib/DBIx/Class/ResultSet.pm
@@ -2712,6 +2712,23 @@ all in the call to C, even when set to C.
See also L and L. For information on how to declare
unique constraints, see L.
+If you need to know if an existing row was found or a new one created use
+L and L instead. Don't forget
+to call L to save the newly created row to the
+database!
+
+ my $cd = $schema->resultset('CD')->find_or_new({
+ cdid => 5,
+ artist => 'Massive Attack',
+ title => 'Mezzanine',
+ year => 2005,
+ });
+
+ if( $cd->in_storage ) {
+ # do some stuff
+ $cd->insert;
+ }
+
=cut
sub find_or_create {
@@ -2773,6 +2790,25 @@ all in the call to C, even when set to C.
See also L and L. For information on how to declare
unique constraints, see L.
+If you need to know if an existing row was updated or a new one created use
+L and L instead. Don't forget
+to call L to save the newly created row to the
+database!
+
+ my $cd = $schema->resultset('CD')->update_or_new(
+ {
+ artist => 'Massive Attack',
+ title => 'Mezzanine',
+ year => 1998,
+ },
+ { key => 'cd_artist_title' }
+ );
+
+ if( $cd->in_storage ) {
+ # do some stuff
+ $cd->insert;
+ }
+
=cut
sub update_or_create {
@@ -3062,9 +3098,9 @@ source alias of the current result set:
my $me = $self->current_source_alias;
- return $self->search(
+ return $self->search({
"$me.modified" => $user->id,
- );
+ });
}
=cut