Class:...ieveAll(3pm)

πŸ“¦
version 1.04 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Class::DBI::Plugin::RetrieveAll πŸ’–

okay bestie, so this page is from the Class:...ieveAll(3pm) manual (yes that's the truncated name, she's mysterious like that ✨) and it's User Contributed Perl Documentation, which basically means a real one wrote it for us. Let's get into it 🫢


🌸 NAME 🌸

Class::DBI::Plugin::RetrieveAll β€” it's giving more complex retrieve_all() for Class::DBI. periodt. πŸ’…


✨ SYNOPSIS ✨

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;

like, that's it. that's the whole vibe. two ways in, both slay. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a simple plugin for a Class::DBI subclass, and what it does is let you do simple sorting of the results of a retrieve_all(). lowkey iconic behaviour, no cap.

There are two main ways to use this, bestie, so pick your fighter:

  1. First up, we create a brand new method called retrieve_all_sorted_by, which takes an argument telling it how to sort. 🌈
  2. We also add a method for retrieve_all_sort_field that sets a default field that any retrieve_all() will use for sorting. πŸ’«

πŸ‘‘ METHODS πŸ‘‘

πŸ’œ retrieve_all_sorted_by

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

This method gets exported into the calling class, and it lets you retrieve all the objects of the class, sorted by the given column. yes ma'am. πŸ”₯

⚠️ okay so listen β€” the argument you give is passed straight through to the database "as is", and it is not checked in any way. so if there's an error here, it'll usually show up as an error from the database rather than from Class::DBI itself. so like… be careful, bestie, fr fr. 😭

The way that this makes it possible to pass more complex ORDER BY clauses through?? obsessed:

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

πŸ’™ retrieve_all_sort_field

__PACKAGE__->retrieve_all_sort_field('date');

This method changes the default retrieve_all() in the Class so it's auto-sorted by the field you gave it. and again β€” it gets passed through directly, so you can have complex ORDER BY clauses here too. versatile queen. πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

Tony Bowden β€” thank you for your service, king πŸ«‘πŸ’–


πŸ› BUGS and QUERIES πŸ›

Please direct all correspondence regarding this module to:

bug-Class-DBI-Plugin-RetrieveAll@rt.cpan.org

like if something's broken or you just have questions, that's the inbox, bestie. don't be shy. πŸ’Œ


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. slay, open source behavior, we love to see it. 🌸


and that's the whole page, babe! this one came to you courtesy of perl v5.36.0 and it's dated 2022-12-07 (the manual name got squished down to Class:...ieveAll(3pm) again, we love a mysterious icon πŸ’…). stay sorted, stay iconic, mwah 🫢✨

πŸ“¦ where this page comes from