X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=4efaeffdc121c50090b0054a8117f9727de8cbe2;hp=f6812592f5a90fae144e0d40cf24e0e15b253142;hb=a014f2e125028a5a80c0587f36df5e865b70b47f;hpb=5d9a5e54a74950b0e62264abcd53e77607f04b48 diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index f6812592f..4efaeffdc 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -688,6 +688,24 @@ sub modified { $self->{'modified'}; } +=item select_for_update + +Selects this record with the SQL "FOR UPDATE" command. This can be useful as +a mutex. + +=cut + +sub select_for_update { + my $self = shift; + my $primary_key = $self->primary_key; + qsearchs( { + 'select' => '*', + 'table' => $self->table, + 'hashref' => { $primary_key => $self->$primary_key() }, + 'extra_sql' => 'FOR UPDATE', + } ); +} + =item insert Inserts this record to the database. If there is an error, returns the error,