Class:...ieveAll(3pm)
π 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:
- First up, we create a brand new method called
retrieve_all_sorted_by, which takes an argument telling it how to sort. π - We also add a method for
retrieve_all_sort_fieldthat sets a default field that anyretrieve_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 and LICENSE π
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
- debian bookworm: libclass-dbi-plugin-retrieveall-perl 1.04-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-dbi-plugin-retrieveall-perl 1.04-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-dbi-plugin-retrieveall-perl 1.04-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-dbi-plugin-retrieveall-perl 1.04-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-dbi-plugin-retrieveall-perl 1.04-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms