.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "RoPkg::DBCollection 3pm" .TH RoPkg::DBCollection 3pm "2021-12-26" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RoPkg::DBCollection \- base class who can be used for collections of database objects .SH "VERSION" .IX Header "VERSION" 0.1.3 .SH "DESCRIPTION" .IX Header "DESCRIPTION" RoPkg::DBCollection is a class who can be used as a base class for database collection of objects. Is used by \fIRoPkg::Simba::Mirrors\fR ,\fIRoPkg::Simba::Commands\fR and \fIRoPkg::Simba::Excludes\fR. This class should not be used directly in applications but derived. .SH "SUBROUTINES/METHODS" .IX Header "SUBROUTINES/METHODS" .SS "\fBnew()\fP" .IX Subsection "new()" The class constructor. Accepts a hash with parameters. The parameters who can be passed to \fBnew()\fR are: .IP "dbo \- database object (instance of RoPkg::DB)" 3 .IX Item "dbo - database object (instance of RoPkg::DB)" .PD 0 .IP "dbo_method \- database method (for use with RoPkg::DB)" 3 .IX Item "dbo_method - database method (for use with RoPkg::DB)" .IP "table \- the sql table name where the objects data can be found" 3 .IX Item "table - the sql table name where the objects data can be found" .PD .PP If you don't specify the \fBdbo\fR and \fBdbo_method\fR parameters, a \fIParam::Missing\fR exception is raised. .SS "\fBdbh()\fP" .IX Subsection "dbh()" returns the database handler (\s-1DBI\s0 object) used by the class. .SS "_count($fields)" .IX Subsection "_count($fields)" Returns the number of records who match the fields specified in \&\f(CW$fields\fR. This method should be overriden by the child classes. The \f(CW$fields\fR must me specified in SQL::Abstract format. Please refer to the SQL::Abstract documentation for more details about \&\f(CW$fields\fR format. .ie n .SS "_get($class_name, $fields, $order_by)" .el .SS "_get($class_name, \f(CW$fields\fP, \f(CW$order_by\fP)" .IX Subsection "_get($class_name, $fields, $order_by)" Returns a array of initialized objects. The values are read from the database. \f(CW$class_name\fR is the name of the class who's gonna be instanciated. When creating the class instance dbo and dbo_method parameters are passed to the \fBnew()\fR method. The records from the database must match the \f(CW$fields\fR parameter and the order is given by \f(CW$order_by\fR. For more details of these 2 parameters please refer to SQL::Abstract documentation. Exceptions throwed: .ie n .IP "\fBParam::Missing\fR \- when $class_name has not been specified" 3 .el .IP "\fBParam::Missing\fR \- when \f(CW$class_name\fR has not been specified" 3 .IX Item "Param::Missing - when $class_name has not been specified" .PD 0 .ie n .IP "\fBParam::Wrong\fR \- when $class_name is not a class name" 3 .el .IP "\fBParam::Wrong\fR \- when \f(CW$class_name\fR is not a class name" 3 .IX Item "Param::Wrong - when $class_name is not a class name" .IP "\fBDB::NoResults\fR \- when the query returned 0 results" 3 .IX Item "DB::NoResults - when the query returned 0 results" .PD .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package RoPkg::Tester; \& \& use strict; \& use warnings; \& \& use Scalar::Util qw(blessed); \& use RoPkg::Exceptions; \& use RoPkg::DBCollection; \& use vars qw(@ISA); \& \& @ISA=qw(RoPkg::DBCollection); \& \& sub new { \& my ($class, %opt) = @_; \& my $self; \& \& $self = $class\->SUPER::new(%opt); \& $self\->{table} = \*(AqMirrors\*(Aq; \& \& return $self; \& } \& \& sub Count { \& my ($self) = @_; \& \& if (!blessed($self)) { \& OutsideClass\->throw( \& error => \*(AqCalled outside class instance\*(Aq, \& pkg_name => \*(AqRoPkg::Tester\*(Aq, \& ); \& } \& \& return $self\->_count(); \& } \& \& sub Get { \& my ($self, $fields) = @_; \& \& if (!blessed($self)) { \& OutsideClass\->throw( \& error => \*(AqCalled outside class instance\*(Aq, \& pkg_name => \*(AqRoPkg::Tester\*(Aq \& ); \& } \& \& return $self\->_get(\*(AqRoPkg::Simba::Mirror\*(Aq); \& } \& \& 1; \& \& sub main { \& my ($dbc, $dbp); \& \& $dbp = new RoPkg::DB(); \& $dbp\->Add( \& \*(Aqdbi:mysql:database=mirrors_db;host=localhost\*(Aq, \& \*(Aqroot\*(Aq, \& \*(Aq\*(Aq, \& \*(Aqmirrors\*(Aq \& ); \& \& $dbc = new RoPkg::Tester( \& dbo => $dbp, \& dbo_method => \*(Aqdb_mirrors\*(Aq \& ); \& \& print $dbc\->Count(),$/; \& \& my @mirrors = $dbc\->Get(); \& } \& \& main(); .Ve .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" This module comes with tests. To run them, unpack the source and use \&'make test' command. .SH "PERL CRITIC" .IX Header "PERL CRITIC" This modules is perlcritic level 2 compliant (with 1 exception) .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" This module does not use any configuration files or environment variables. However, it is possible that some dependencies to do so. Please read the man page of each dependency to find out more information. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" This module use the following modules: .IP "*) SQL::Abstract" 4 .IX Item "*) SQL::Abstract" .PD 0 .IP "*) \s-1DBI\s0" 4 .IX Item "*) DBI" .IP "*) Scalar::Util" 4 .IX Item "*) Scalar::Util" .IP "*) RoPkg" 4 .IX Item "*) RoPkg" .PD .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" None known to the author .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" None known to the author .SH "SEE ALSO" .IX Header "SEE ALSO" RoPkg::Exceptions RoPkg::DB RoPkg::DBObject RoPkg::Simba::Mirrors .SH "AUTHOR" .IX Header "AUTHOR" Subredu Manuel .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright (C) 2006 Subredu Manuel. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The \s-1LICENSE\s0 file contains the full text of the license.