ORDB::CPAN::Mandriva::Module - orlite for module table in database


ORDB-CPAN-Mandriva documentation  | view source Contained in the ORDB-CPAN-Mandriva distribution.

Index


NAME

Top

ORDB::CPAN::Mandriva::Module - orlite for module table in database

VERSION

Top

version 1.100230

DESCRIPTION

Top

This class models the module table in the database. It can be used either with class methods, or as objects mapping one row of the table.

ATTRIBUTES

Top

my $str = $module->module;

The name of the module, eg ORDB::CPAN::Mandriva.

my $str = $module->version;

The version of the module (not the dist, nor the package). It may be null.

my $str = $module->dist;

This is the CPAN distribution the module is part of, eg ORDB-CPAN-Mandriva. It may be null.

my $str = $module->pkgname;

This is the name of the package holding this module in Mandriva Linux distribution. Chances are that it looks like perl-ORDB-CPAN-Mandriva.

METHODS

Top

select

    # Get all objects in list context
    my @list = ORDB::CPAN::Mandriva::Module->select;

    # Get a subset of objects in scalar context
    my $array_ref = ORDB::CPAN::Mandriva::Module->select(
        'where pkgname = ? order by module',
        'perl-ORDB-CPAN-Mandriva',
    );

The select method executes a typical SQL SELECT query on the module table.

It takes an optional argument of a SQL phrase to be added after the FROM module section of the query, followed by variables to be bound to the placeholders in the SQL phrase. Any SQL that is compatible with SQLite can be used in the parameter.

Returns a list of ORDB::CPAN::Mandriva::Module objects when called in list context, or a reference to an ARRAY of ORDB::CPAN::Mandriva::Module objects when called in scalar context.

Throws an exception on error, typically directly from the DBI layer.

count

    # How many objects are in the table
    my $rows = ORDB::CPAN::Mandriva::Module->count;

    # How many objects
    my $small = ORDB::CPAN::Mandriva::Module->count(
        'where pkgname = ?',
        'perl-ORDB-CPAN-Mandriva',
    );

The count method executes a SELECT COUNT(*) query on the module table.

It takes an optional argument of a SQL phrase to be added after the FROM module section of the query, followed by variables to be bound to the placeholders in the SQL phrase. Any SQL that is compatible with SQLite can be used in the parameter.

Returns the number of objects that match the condition.

Throws an exception on error, typically directly from the DBI layer.

my $module = Module->new(%params);

The new constructor is used to create a new abstract object that is not (yet) written to the database.

Returns a new ORDB::CPAN::Mandriva::Module object.

$module->insert;

The insert method commits a new object (created with the new method) into the database.

Returns the object itself as a convenience, or throws an exception on error, typically from the DBI layer.

delete

    # Delete a single instantiated object
    $object->delete;

    # Delete multiple rows from the module table
    ORDB::CPAN::Mandriva::Module->delete(
        'where pkgname = ?',
        'perl-ORDB-CPAN-Mandriva'
    );

The delete method can be used in a class form and an instance form.

When used on an existing ORDB::CPAN::Mandriva::Module instance, the delete method removes that specific instance from the module, leaving the object intact for you to deal with post-delete actions as you wish.

When used as a class method, it takes a compulsory argument of a SQL phrase to be added after the DELETE FROM module section of the query, followed by variables to be bound to the placeholders in the SQL phrase. Any SQL that is compatible with SQLite can be used in the parameter.

Returns true on success or throws an exception on error, or if you attempt to call delete without a SQL condition phrase.

truncate

    # Delete all records in the module table
    ORDB::CPAN::Mandriva::Module->truncate;

To prevent the common and extremely dangerous error case where deletion is called accidentally without providing a condition, the use of the delete method without a specific condition is forbidden.

Instead, the distinct method truncate is provided to delete all records in a table with specific intent.

Returns true, or throws an exception on error.

my $module = Module->create(%params);

The create constructor is a one-step combination of new and insert that takes the column parameters, creates a new ORDB::CPAN::Mandriva::Module object, inserts the appropriate row into the module table, and then returns the object.

Returns a new Module object, or throws an exception on error, typically from the DBI layer.

AUTHOR

Top

  Jerome Quelin

COPYRIGHT AND LICENSE

Top


ORDB-CPAN-Mandriva documentation  | view source Contained in the ORDB-CPAN-Mandriva distribution.