
Apache::Voodoo::Table - framework to handle common database operations

FIXME FIXME Add the TONS of necessary documentation FIXME

{
table => 'table name',
primary_key => 'column name' OR [ 'column', 'column2' ],
primary_key_user_supplied => 0 | 1 (defaults to 0),
primary_key_regexp => regular_expression (defaults to ^\d+$)
columns => {
name1 => {
type => varchar,
length => +int or -1 for unlimited
valid => 'email' |'url'| $code_ref
--- Common to all data types ---
regexp => regexp it must match.
unique => 0|1 if (the column must be unique)
required => 0|1
references => {
table => 'name'
primary_key => 'column'
columns => 'column name' OR [ 'column1', 'column2', 'column3' ]
select_label => column or sql concat(foo,bar,baz)
select_default => primary_key value for default selected
select_extra => 'order by foo or where stuff order by foo, etc.'
}
},
name2 => {
type => unsigned_int
max => maximum value
},
name3 => {
type => signed_int
max => maximum value
min => minimum value
},
name4 => {
type => (un)signed_decimal
left => number of digits to left of decimal
right => number of digits to right of decimal
},
name5 => {
type => date,
min => minimum date (optional) -- magic value: 'now' date must be >= today's date
max => maximum date (optional) -- magic value: 'now' date must be <= today's date
},
name6 => {
type => time
},
name7 => {
type => bit
},
name8 => {
type => password (proposed magic type handling passwords,
would assume varchar(32) not null as the column type
using Crypt::passwdMD5
)
}
},
list_options => {
default_sort => 'sort_name'
sort => {
'sort_name' => [ column, column2, referenced_table.column, referenced_table.column2 ]
'sort_name2' => [ column3, column4, referenced_table.column2 ]
},
search => [
['select list label','column'],
['select list label2','referenced_table.column']
]
}
}

Returns 1 if the the last operation was "successful"
Returns details on the columns that we changed via edit. Useful for producing a detailed audit log.
Return structure looks like:
[
[ 'column name','old value','new value' ]
]
Adds a data validation routine to the add function
Adds a data validation routine to the edit function
performs a database insertion
performs a database update
performs a delete from a table
list all or part of the rows in a table
Displays a particular row from the table
Toggles the column specified by the second parameter

Maverick, /\/\averick@smurfbaneDOTorg

Copyright (c) 2005 Steven Edwards. All rights reserved.
You may use and distribute Voodoo under the terms described in the LICENSE file include in this package or Apache::Voodoo::license. The summary is it's a legalese version of the Artistic License :)