Gantry::Plugins::AutoCRUDHelper::CDBI - the actual CRUD for CDBI AutoCRUD


Gantry documentation Contained in the Gantry distribution.

Index


Code Index:

NAME

Top

Gantry::Plugins::AutoCRUDHelper::CDBI - the actual CRUD for CDBI AutoCRUD

SYNOPSIS

Top

This module is used for you by Gantry::Plugins::AutoCRUD. It is in fact the default helper. It supports Class::DBI models which inherit from Gantry::Utils::CDBI.

DESCRIPTION

Top

Inside Gantry::Plugins::AutoCRUD, whenever actual database work needs to be done, your model is asked to supply a helper by calling its get_orm_helper method. If that method returns 'Gantry::Plugins::AutoCRUDHelper::CDBI' or that method is missing, this module is used to do database work.

METHODS

Top

The methods of this module are documented in Gantry::Plugins::AutoCRUD, but here is a list for completeness (and to keep POD testers happy):

insert
retrieve
update
delete

SEE ALSO

Top

    Gantry::Plugins::AutoCRUDHelper
    Gantry::Plugins::AutoCRUDHelper::DBIxClass

AUTHOR

Top

Phil Crow <philcrow2000@yahoo.com>

COPYRIGHT and LICENSE

Top


Gantry documentation Contained in the Gantry distribution.

package Gantry::Plugins::AutoCRUDHelper::CDBI;
use strict;

sub insert {
    my $class       = shift;
    my $gantry_site = shift;
    my $params      = shift;
    my $new_row     = $gantry_site->get_model_name->create( $params );

    $new_row->dbi_commit();

    return $new_row;
}

sub retrieve {
    my $class       = shift;
    my $gantry_site = shift;
    my $id          = shift;

    return $gantry_site->get_model_name()->retrieve( $id );
}

sub update {
    my $class       = shift;
    my $gantry_site = shift;
    my $row         = shift;
    my $params      = shift;

    $row->set( %{ $params } );
    $row->update;
    $row->dbi_commit;   # XXX check autocommit flag
}

sub delete {
    my $class       = shift;
    my $gantry_site = shift;
    my $row         = shift;

    $row->delete;
    $gantry_site->get_model_name()->dbi_commit();
}

1;