GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::CLASS::HELPER::RESULTSET::SHORTCUT (3)

.ds Aq ’

NAME

DBIx::Class::Helper::ResultSet::Shortcut - Shortcuts to common searches (->order_by, etc)

CONTENTS

SYNOPSIS



 package MyApp::Schema::ResultSet::Foo;

 __PACKAGE__->load_components(qw{Helper::ResultSet::Shortcut});

 ...

 1;



And then elsewhere:



 # lets say you grab a resultset from somewhere else
 my $foo_rs = get_common_rs()
 # but Id like it sorted!
   ->order_by({ -desc => power_level })
 # and without those other dumb columns
   ->columns([qw/cromulence_ratio has_jimmies_rustled/])
 # but get rid of those duplicates
   ->distinct
 # and put those straight into hashrefs, please
   ->hri
 # but only give me the first 3
   ->rows(3);



DESCRIPTION

This helper provides convenience methods for resultset modifications.

See NOTE in DBIx::Class::Helper::ResultSet for a nice way to apply it to your entire schema.

SEE ALSO

This component is actually a number of other components put together. It will get more components added to it over time. If you are worried about all the extra methods you won’t use or something, using the individual shortcuts is a simple solution. All the documentation will remain here, but the individual components are:
o DBIx::Class::Helper::ResultSet::Shortcut::HRI
o DBIx::Class::Helper::ResultSet::Shortcut::OrderBy
o DBIx::Class::Helper::ResultSet::Shortcut::OrderByMagic

(adds the magic string functionality to DBIx::Class::Helper::ResultSet::Shortcut::OrderBy))

o DBIx::Class::Helper::ResultSet::Shortcut::GroupBy
o DBIx::Class::Helper::ResultSet::Shortcut::Distinct
o DBIx::Class::Helper::ResultSet::Shortcut::Rows
o DBIx::Class::Helper::ResultSet::Shortcut::Limit

(inherits from DBIx::Class::Helper::ResultSet::Shortcut::Rows)

o DBIx::Class::Helper::ResultSet::Shortcut::HasRows

(inherits from DBIx::Class::Helper::ResultSet::Shortcut::Rows)

o DBIx::Class::Helper::ResultSet::Shortcut::Columns
o DBIx::Class::Helper::ResultSet::Shortcut::AddColumns
o DBIx::Class::Helper::ResultSet::Shortcut::Page
o DBIx::Class::Helper::ResultSet::Shortcut::LimitedPage

(inherits from DBIx::Class::Helper::ResultSet::Shortcut::Page and DBIx::Class::Helper::ResultSet::Shortcut::Rows)

o DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist

METHODS

    distinct



 $foo_rs->distinct

 # equivalent to...
 $foo_rs->search(undef, { distinct => 1 });



    group_by



 $foo_rs->group_by([ qw/ some column names /])

 # equivalent to...
 $foo_rs->search(undef, { group_by => [ qw/ some column names /] });



    order_by



 $foo_rs->order_by({ -desc => col1 });

 # equivalent to...
 $foo_rs->search(undef, { order_by => { -desc => col1 } });



You can also specify the order as a magic string, e.g.:



 $foo_rs->order_by(!col1)       # ->order_by({ -desc => col1 })
 $foo_rs->order_by(col1,col2)   # ->order_by([qw(col1 col2)])
 $foo_rs->order_by(col1,!col2)  # ->order_by([{ -asc => col1 }, { -desc => col2 }])
 $foo_rs->order_by(qw(col1 col2)) # ->order_by([qw(col1 col2)])



Can mix it all up as well:



 $foo_rs->order_by(qw(col1 col2 col3), col4,!col5)



    hri



 $foo_rs->hri;

 # equivalent to...
 $foo_rs->search(undef, {
    result_class => DBIx::Class::ResultClass::HashRefInflator
 });



    rows



 $foo_rs->rows(10);

 # equivalent to...
 $foo_rs->search(undef, { rows => 10 })



    limit

This is an alias for rows.



  $foo_rs->limit(10);

  # equivalent to...
  $foo_rs->rows(10);



    has_rows

A lighter way to check the resultset contains any data rather than calling $rs->count.

    page



 $foo_rs->page(2);

 # equivalent to...
 $foo_rs->search(undef, { page => 2 })



    limited_page



 $foo_rs->limited_page(2, 3);

 # equivalent to...
 $foo_rs->search(undef, { page => 2, rows => 3 })



    columns



 $foo_rs->columns([qw/ some column names /]);

 # equivalent to...
 $foo_rs->search(undef, { columns => [qw/ some column names /] });



    add_columns



 $foo_rs->add_columns([qw/ some column names /]);

 # equivalent to...
 $foo_rs->search(undef, { +columns => [qw/ some column names /] });



    prefetch



 $foo_rs->prefetch(bar);

 # equivalent to...
 $foo_rs->search(undef, { prefetch => bar });



    results_exist



 my $results_exist = $schema->resultset(Bar)->search({...})->results_exist;



Uses EXISTS SQL function to check if the query would return anything. Possibly lighter weight than the much more common foo() if $rs->count idiom.

    null(@columns || \@columns)



 $rs->null(status);
 $rs->null([status, title]);



    not_null(@columns || \@columns)



 $rs->not_null(status);
 $rs->not_null([status, title]);



like($column || \@columns, CW$cond)



 $rs->like(lyrics, %zebra%);
 $rs->like([lyrics, title], %zebra%);



not_like($column || \@columns, CW$cond)



 $rs->not_like(lyrics, %zebra%);
 $rs->not_like([lyrics, title], %zebra%);



AUTHOR

Arthur Axel fREW Schmidt <frioux+cpan@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Arthur Axel fREW Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBIX::CLASS::HELPER::RESULTSET::SHORTCUT (3) 2015-11-07

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.