|
NAMEGantry::Plugins::DBIxClassConn - DBIx::Class schema accessor mixinSYNOPSISIn any controller:use YourModel; use YourAuthModel; sub schema_base_class { return 'YourModel'; } sub schema_auth_base_class { return 'YourAuthModel'; } use Gantry::Plugins::DBIxClassConn; sub some_method { my $self = shift; #... my $schema = $self->get_schema; # Use $schema as instructed in DBIx::Class docs. } sub some_auth_method { my $self = shift; my $auth_schema = $self->get_auth_schema(); } package YourModel; sub get_db_options { return { AutoCommit => 1 }; # or whatever options you want } package YourAuthModel; sub get_db_options { return { AutoCommit => 1 }; # or whatever options you want } Alternatively, in your controller which uses Gantry::Plugins::DBIxClassConn: sub some_method { my $self = shift; my @rows = $MY_TABLE->gsearch( $self, { ... }, { ... } ); } DESCRIPTIONThis mixin gives you an accessor which returns the DBIx::Class schema object for your data model. It expects dbconn, dbuser, and dbpass to be in your site conf, so it can call fish config to get them. If you use get_auth_schema, it expects auth_dbconn, auth_dbuser and auth_dbpass to be in your site conf.In order for this module to help you, your model (and/or auth model) must provide one helper:
If you model inherits from Gantry::Utils::DBIxClass, it will have a family of convenience methods meant to reduce typing. These are the same methods DBIx::Class makes available through resultsets, but with a couple of twists. First, the names of the methods have a g in front. Second, the g methods expect to be called as class methods on the model. Third, the g methods expect the Gantry site object as their first (non-invoking) parameter. The rest of the parameters are the same as for the corresponding call via a DBIC resultset. Note that for the g methods to work on the model, your site object must use this mixin. The g methods call get_schema. METHOD EXPORTED into YOUR PACKAGE
SEE ALSOGantry::Docs::DBConn, Gantry::Utils::ModelHelper, but only if you use a different ORM than DBIx::Class.AUTHORPhil Crow <philcrow2000@yahoo.com>COPYRIGHT and LICENSECopyright (c) 2006, Phil CrowThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
Visit the GSP FreeBSD Man Page Interface. |