X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=4efaeffdc121c50090b0054a8117f9727de8cbe2;hb=a014f2e125028a5a80c0587f36df5e865b70b47f;hp=6b7e8d5fa3ea63c40ee2d2475d66e2e400a3cff5;hpb=f01e2ce0aa6c1925e6266d78797025ec68bfac07;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 6b7e8d5fa..4efaeffdc 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -26,7 +26,7 @@ use Tie::IxHash; #export dbdef for now... everything else expects to find it here @EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef jsearch); -$DEBUG = 3; +$DEBUG = 0; $me = '[FS::Record]'; $nowarn_identical = 0; @@ -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,