5 use FS::Record qw( qsearch qsearchs dbh );
12 FS::queue - Object methods for queue records
18 $record = new FS::queue \%hash;
19 $record = new FS::queue { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::queue object represents an queued job. FS::queue inherits from
32 FS::Record. The following fields are currently supported:
36 =item jobnum - primary key
38 =item job - fully-qualified subroutine name
40 =item status - job status
50 Creates a new job. To add the example to the database, see L<"insert">.
52 Note that this stores the hash reference, not a distinct copy of the hash it
53 points to. You can ask the object for a copy with the I<hash> method.
57 # the new method can be inherited from FS::Record, if a table method is defined
59 sub table { 'queue'; }
61 =item insert [ ARGUMENT, ARGUMENT... ]
63 Adds this record to the database. If there is an error, returns the error,
64 otherwise returns false.
66 If any arguments are supplied, a queue_arg record for each argument is also
67 created (see L<FS::queue_arg>).
74 local $SIG{HUP} = 'IGNORE';
75 local $SIG{INT} = 'IGNORE';
76 local $SIG{QUIT} = 'IGNORE';
77 local $SIG{TERM} = 'IGNORE';
78 local $SIG{TSTP} = 'IGNORE';
79 local $SIG{PIPE} = 'IGNORE';
81 my $oldAutoCommit = $FS::UID::AutoCommit;
82 local $FS::UID::AutoCommit = 0;
85 my $error = $self->SUPER::insert;
87 $dbh->rollback if $oldAutoCommit;
91 foreach my $arg ( @_ ) {
92 my $queue_arg = new FS::queue_arg ( {
93 'jobnum' => $self->jobnum,
96 $error = $queue_arg->insert;
98 $dbh->rollback if $oldAutoCommit;
103 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
111 Delete this record from the database.
115 # the delete method can be inherited from FS::Record
117 =item replace OLD_RECORD
119 Replaces the OLD_RECORD with this one in the database. If there is an error,
120 returns the error, otherwise returns false.
124 # the replace method can be inherited from FS::Record
128 Checks all fields to make sure this is a valid job. If there is
129 an error, returns the error, otherwise returns false. Called by the insert
137 $self->ut_numbern('jobnum')
138 || $self->ut_anything('job')
139 || $self->ut_numbern('_date')
140 || $self->ut_enum('status',['', qw( new locked failed )])
142 return $error if $error;
144 $self->status('new') unless $self->status;
145 $self->_date(time) unless $self->_date;
156 map $_->arg, qsearch( 'queue_arg', { 'jobnum' => $self->jobnum } );
163 $Id: queue.pm,v 1.1 2001-09-11 00:08:18 ivan Exp $
169 L<FS::Record>, schema.html from the base documentation.