1 package Maypole::Model::CDBI::Plain;
3 use base 'Maypole::Model::CDBI';
6 Maypole::Config->mk_accessors(qw(table_to_class));
10 Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
15 use 'Maypole::Application';
17 Foo->config->model("Maypole::Model::CDBI::Plain");
18 Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
20 # untaint columns and provide custom actions for each class
22 Foo::SomeTable->untaint_columns(email => ['email'], printable => [qw/name description/]);
24 Foo::Other::Table->untaint_columns ( ... );
26 sub Foo::SomeTable::SomeAction : Exported {
34 This module allows you to use Maypole with previously set-up
35 L<Class::DBI> classes; simply call C<setup> with a list reference
36 of the classes you're going to use, and Maypole will work out the
37 tables and set up the inheritance relationships as normal.
43 This method is inherited from Maypole::Model::Base and calls setup_database,
44 which uses Class::DBI::Loader to create and load Class::DBI classes from
45 the given database schema.
49 This method loads the model classes for the application
56 my ( $self, $config, $namespace, $classes ) = @_;
57 $config->{classes} = $classes;
58 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
59 $namespace->model_classes_loaded(1);
60 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
61 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
66 returns class for given table
71 my ( $self, $r, $table ) = @_;
72 return $r->config->{table_to_class}->{$table};
77 This class method is passed the name of a model class that represensts a table
78 and allows the master model class to do any set-up required.
83 my ( $self, $child ) = @_;
84 if ( my $col = $child->stringify_column ) {
85 $child->columns( Stringify => $col );
91 L<Maypole::Model::Base>
93 L<Maypole::Model::CDBI>