1 package Maypole::Model::CDBI::Plain;
4 use base 'Maypole::Model::CDBI';
7 Maypole::Config->mk_accessors(qw(table_to_class));
11 Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
16 use 'Maypole::Application';
18 Foo->config->model("Maypole::Model::CDBI::Plain");
19 Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
21 # untaint columns and provide custom actions for each class
23 Foo::SomeTable->untaint_columns(email => ['email'], printable => [qw/name description/]);
25 Foo::Other::Table->untaint_columns ( ... );
27 sub Foo::SomeTable::SomeAction : Exported {
35 This module allows you to use Maypole with previously set-up
36 L<Class::DBI> classes; simply call C<setup> with a list reference
37 of the classes you're going to use, and Maypole will work out the
38 tables and set up the inheritance relationships as normal.
44 This method is inherited from Maypole::Model::Base and calls setup_database,
45 which uses Class::DBI::Loader to create and load Class::DBI classes from
46 the given database schema.
50 This method loads the model classes for the application
57 my ( $self, $config, $namespace, $classes ) = @_;
58 $config->{classes} = $classes;
59 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
60 $namespace->model_classes_loaded(1);
61 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
62 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
67 returns class for given table
72 my ( $self, $r, $table ) = @_;
73 return $r->config->{table_to_class}->{$table};
78 This class method is passed the name of a model class that represensts a table
79 and allows the master model class to do any set-up required.
84 my ( $self, $child ) = @_;
85 if ( my $col = $child->stringify_column ) {
86 $child->columns( Stringify => $col );
92 L<Maypole::Model::Base>
94 L<Maypole::Model::CDBI>