GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Gantry::Plugins::DBIxClassConn(3) User Contributed Perl Documentation Gantry::Plugins::DBIxClassConn(3)

Gantry::Plugins::DBIxClassConn - DBIx::Class schema accessor mixin

In 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, { ... }, { ... } );
    }

This 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:

get_db_options
This supplies the default DBI parameters to the connection method. This is usually sufficient:

    sub get_db_options { return {}; }
    

Note that the return value must be a hash reference.

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.

get_schema
Exported.

Returns a DBIx::Class schema ready for use (if you set up your connection info in the right way, see Gantry::Docs::DBConn).

get_auth_schema
Exported.

Returns a DBIx::Class schema ready for use (if you set up your connection info in the right way, see Gantry::Docs::DBConn).

Gantry::Docs::DBConn, Gantry::Utils::ModelHelper, but only if you use a different ORM than DBIx::Class.

Phil Crow <philcrow2000@yahoo.com>

Copyright (c) 2006, Phil Crow

This 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.

2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.