Roger Pettett
and 1 contributors

NAME

ClearPress::model - a base class for the data-model of the ClearPress MVC family

VERSION

$LastChangedRevision: 12 $

SYNOPSIS

 use strict;
 use warning;
 use base qw(ClearPress::model);

 __PACKAGE__->mk_accessors(__PACKAGE__->fields());

 sub fields { return qw(...); }

DESCRIPTION

SUBROUTINES/METHODS

fields

  my @aFields = $oSelf->fields();
  my @aFields = __PACKAGE__->fields();

primary_key - usually the first element of fields();

  my $sPrimaryKey = $oSelf->fields();

table - database table name this class represents

  my $sTableName = $oSelf->table();

init - post-constructor hook, called by new();

new - Constructor

  my $oInstance = ClearPress::model::subclass->new();

util - ClearPress::util object

  my $oUtil = ClearPress::model::subclass->util();

  my $oUtil = $oInstance->util();

get - generic 'get' accessor, derived from Class::Accessor.

 Invokes $self->read() if necessary.

 my $sFieldValue = $oSelf->get($sFieldName);

gen_getarray - Arrayref of objects of a given type for a given database query

  my $arObjects = $oInstance->gen_getarray('ClearPress::model::subclass',
                                           q(SELECT a,b,c FROM x,y WHERE x.d=? AND y.e=?),
                                           @bind_params);

gen_getall - Arrayref of all objects of type (ref $self) or a given class

  my $arObjects = $self->gen_getall();
  my $arObjects = $self->gen_getall('ClearPress::otherclass');

gen_getobj - An object of a given class based on the value of the primary key in that class equalling the value in the same field-name in this object.

  my $oObj = $self->gen_getobj('application::model::name');

create - Generic INSERT into database

  $oSelf->create();

read - Generic lazy-load from the database

  $oSelf->load();

update - Generic UPDATE into database against primary_key

  $oSelf->update();

delete - Generic delete from database

  $oSelf->delete();

save - Generic save object to database

  $oSelf->save();

DIAGNOSTICS

CONFIGURATION AND ENVIRONMENT

DEPENDENCIES

Class::Accessor ClearPress::util English Carp

INCOMPATIBILITIES

BUGS AND LIMITATIONS

AUTHOR

Roger Pettett, <rpettett@cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2007 Roger Pettett

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.4 or, at your option, any later version of Perl 5 you may have available.