This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / eg / table_template.pm
1 package FS::table_name;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::table_name - Object methods for table_name records
10
11 =head1 SYNOPSIS
12
13   use FS::table_name;
14
15   $record = new FS::table_name \%hash;
16   $record = new FS::table_name { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::table_name object represents an example.  FS::table_name inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item field - description
34
35 =back
36
37 =head1 METHODS
38
39 =over 4
40
41 =item new HASHREF
42
43 Creates a new example.  To add the example to the database, see L<"insert">.
44
45 Note that this stores the hash reference, not a distinct copy of the hash it
46 points to.  You can ask the object for a copy with the I<hash> method.
47
48 =cut
49
50 # the new method can be inherited from FS::Record, if a table method is defined
51
52 sub table { 'table_name'; }
53
54 =item insert
55
56 Adds this record to the database.  If there is an error, returns the error,
57 otherwise returns false.
58
59 =cut
60
61 # the insert method can be inherited from FS::Record
62
63 =item delete
64
65 Delete this record from the database.
66
67 =cut
68
69 # the delete method can be inherited from FS::Record
70
71 =item replace OLD_RECORD
72
73 Replaces the OLD_RECORD with this one in the database.  If there is an error,
74 returns the error, otherwise returns false.
75
76 =cut
77
78 # the replace method can be inherited from FS::Record
79
80 =item check
81
82 Checks all fields to make sure this is a valid example.  If there is
83 an error, returns the error, otherwise returns false.  Called by the insert
84 and replace methods.
85
86 =cut
87
88 # the check method should currently be supplied - FS::Record contains some
89 # data checking routines
90
91 sub check {
92   my $self = shift;
93
94   my $error = 
95     $self->ut_numbern('primary_key')
96     || $self->ut_number('validate_other_fields')
97   ;
98   return $error if $error;
99
100   $self->SUPER::check;
101 }
102
103 =back
104
105 =head1 BUGS
106
107 The author forgot to customize this manpage.
108
109 =head1 SEE ALSO
110
111 L<FS::Record>, schema.html from the base documentation.
112
113 =cut
114
115 1;
116