DBR::Interface::Object An object representing a table about to be queried. This object is the entry point for executing queries against a given table
$dbrh->tableA->all(); $dbrh->tableA->get( $primary_key ); $dbrh->tableA->where( field => 'value' ); $dbrh->tableA->where( 'relationshipB.field' => 'value' );
Constructor for DBR::Interface::Object - Called by DBR::Handle->tablename (autoloaded)
Initiates a database query based on provided constraints.
Arguments: Key value pairs of relationships/fields and values.
Returns: DBR::Query::ResultSet object containing resultant query
# Simple use case: $dbrh->tableA->where( fieldname => $somevalue ); # Constrain by related data: $dbrh->tableA->where( 'relationshipB.fieldX' => $somevalue ); # Constrain by more related data: $dbrh->tableA->where( 'relB.fieldX' => 'value', 'relB.fieldY' => $somevalue, # same relationship twice, different fields - do the right thing 'relC.relD.relE.fieldZ' => $far_removed_value, # ...ad infinitum );
By default, equality comparisons are assumed. ( field = 'value') For other types of comparisons:
use DBR::Util::Operator; # Imports operators into your scope $dbrh->tableA->where( fieldname => NOT 'value' ); $dbrh->tableA->where( fieldname => GT 123 ); $dbrh->tableA->where( fieldname => LT 123 ); $dbrh->tableA->where( fieldname => LIKE 'value%' ); # And so on
For more details, See: DBR::Util::Operator
Initiates a database queryFetch all rows from a given table.
Arguments: single scalar value, or one arrayref of primary key ids.
my $single_record = $dbrh->tablename->get( 123 ); # pkey 123 my $resultset_obj = $dbrh->tablename->get( [ 123, 456 ] );
If given arrayref, Returns a single DBR::Query::ResultSet object containing resultant query
If given single value, Returns a single DBR::Query::Record object (dynamically created)
Initiates a database query with NO constraints. Fetch all rows from a given table.
Arguments: None
To install DBR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBR
CPAN shell
perl -MCPAN -e shell install DBR
For more information on module installation, please visit the detailed CPAN module installation guide.