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
Class::DBI::Plugin::RetrieveAll(3) User Contributed Perl Documentation Class::DBI::Plugin::RetrieveAll(3)

Class::DBI::Plugin::RetrieveAll - more complex retrieve_all() for Class::DBI

        use base 'Class::DBI';
        use Class::DBI::Plugin::RetrieveAll;

        my @by_date = My::Class->retrieve_all_sorted_by("date");

        # or

        __PACKAGE__->retrieve_all_sort_field('date');

        my @by_date = My::Class->retrieve_all;

This is a simple plugin to a Class::DBI subclass that allows for simple sorting of the results of a retrieve_all().

There are two main ways to use this.

Firstly, we create a new method 'retrieve_all_sorted_by' which takes an argument of how to sort.

We also add a method for 'retrieve_all_sort_field' that sets a default field that any retrieve_all() will use for sorting.

        my @by_date = My::Class->retrieve_all_sorted_by("date");

This method will be exported into the calling class, and allows for retrieving all the objects of the class, sorted by the given column.

The argument given will be passed straight through to the database 'as is', and is not checked in any way, so an error here will usually in an error from the database, rather than Class::DBI itself.

This makes it possible to pass more complex ORDER BY clauses through:

        my @by_date = My::Class->retrieve_all_sorted_by("date DESC, reference_no");

  __PACKAGE__->retrieve_all_sort_field('date');

This method changes the default retrieve_all() in the Class to be auto-sorted by the field given. Again this will be passed through directly, so you can have complex ORDER BY clauses.

Tony Bowden

Please direct all correspondence regarding this module to: bug-Class-DBI-Plugin-RetrieveAll@rt.cpan.org

Copyright (C) 2004-2006 Kasei. All rights reserved.

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

2006-01-16 perl v5.32.1

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

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