=head1 SYNOPSIS
- script/create.pl model Foo DBIC::Schema Foo::SchemaClass [ dsn user password ]
+ script/create.pl model Foo DBIC::Schema Foo::SchemaClass [ connect_info arguments ]
- Where:
- Foo is the short name for the Model class being generated
- Foo::SchemaClass is the fully qualified classname of your Schema,
- which isa DBIx::Class::Schema defined elsewhere.
- dsn, user, and password are optional if connection info is already
- defined in your Schema class (as it would be in the case of
- DBIx::Class::Schema::Loader).
+ Where:
+ Foo is the short name for the Model class being generated
+ Foo::SchemaClass is the fully qualified classname of your Schema,
+ which isa DBIx::Class::Schema defined elsewhere.
+ connect_info arguments are the same as what DBIx::Class::Schema::connect
+ expects, and are storage_type-specific. For DBI-based storage, these
+ arguments are the dsn, username, password, and connect options,
+ respectively.
+
+=head1 TYPICAL EXAMPLES
+
+ script/myapp_create.pl model Foo DBIC::Schema FooSchema dbi:mysql:foodb myuname mypass '{ AutoCommit => 1 }'
+
+ # -or, if the schema already has connection info and you want to re-use that:
+ script/myapp_create.pl model Foo DBIC::Schema FooSchema
=head1 DESCRIPTION
=cut
sub mk_compclass {
- my ( $self, $helper, $schema_class, $dsn, $user, $pass ) = @_;
+ my ( $self, $helper, $schema_class, @connect_info) = @_;
$helper->{schema_class} = $schema_class || '';
- if(defined($dsn)) {
+ if(@connect_info) {
$helper->{setup_connect_info} = 1;
- $helper->{dsn} = $dsn || '';
- $helper->{user} = $user || '';
- $helper->{pass} = $pass || '';
+ for(@connect_info) {
+ $_ = qq{'$_'} if $_ !~ /^\s*[[{]/;
+ }
+ $helper->{connect_info} = \@connect_info;
}
my $file = $helper->{file};
__DATA__
+=begin pod_to_ignore
+
__compclass__
package [% class %];
__PACKAGE__->config(
schema_class => '[% schema_class %]',
- [% IF setup_connect_info %]
- connect_info => [ '[% dsn %]',
- '[% user %]',
- '[% pass %]',
- {
- RaiseError => 1,
- PrintError => 0,
- ShowErrorStatement => 1,
- TraceLevel => 0,
- AutoCommit => 1,
- }
- ],
- [% END %]
+ [% IF setup_connect_info %]connect_info => [
+ [% FOREACH arg = connect_info %][% arg %],
+ [% END %]
+ ],[% END %]
);
=head1 NAME