Jifty:...::Union(3pm)

πŸ“¦
version 0.78 Β· 2 versions
  • 0.78 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.78 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Jifty::DBI::Collection::Union β€” the manual page bestie πŸ’–

okay so this is Jifty:...::Union(3pm) from the User Contributed Perl Documentation, and it's literally the "smoosh all ur result sets together" module. let's get into it 🫢


🌸 NAME 🌸

Jifty::DBI::Collection::Union β€” deal with multiple Jifty::DBI::Collection result sets as one πŸŽ€

like, one list to rule them all. no cap.


✨ SYNOPSIS ✨

use Jifty::DBI::Collection::Union;
my $U = new Jifty::DBI::Collection::Union;
$U->add( $tickets1 );
$U->add( $tickets2 );

$U->GotoFirstItem;
while (my $z = $U->Next) {
  printf "%5d %30.30s\n", $z->Id, $z->Subject;
}

see how we just... stacked $tickets1 and $tickets2 into one thing and then iterated like it was always one collection? that's the whole vibe. main character energy fr fr πŸ‘‘


πŸ’€ WARNING πŸ’€

This module is still experimental. πŸ™ˆ

like it works but also. bestie. be aware.


🌈 DESCRIPTION 🌈

so what this actually does: it implements a subset of the Jifty::DBI::Collection methods β€” not all of them, just enough to do iteration over a bunch of results πŸ¦‹.

it's useful for displaying the results of two unrelated searches (for the same kind of objects) in a single list. iconic behaviour honestly.


πŸ’… METHODS πŸ’…

πŸ“ new

Create a new Jifty::DBI::Collection::Union object. No arguments.

that's it. that's the whole thing. so simple, so clean ✨

🧚 add COLLECTION

Add Jifty::DBI::Collection object COLLECTION to the Union object.

It must be the same type as the first object added. ⚠️

like don't be out here mixing object types, the Union will simply not have it πŸ’…

🌸 first

Return the very first element of the Union (which is the first element of the first Collection). Also reset the current pointer to that element.

so it returns it and rewinds u there. two-for-one πŸŽ€

⭐ next

Return the next element in the Union.

just vibing forward through the list, one item at a time πŸ¦‹

πŸ”₯ last

Returns the last item.

the final boss. the end of the list. periodt.

πŸ‘‘ count

Returns the total number of elements in the union collection.

yes bestie we're counting everything across all the smooshed-together collections πŸ’–

πŸ’œ goto_first_item

Starts the recordset counter over from the first item. the next time you call next, you'll get the first item returned by the database, as if you'd just started iterating through the result set.

it's giving "rewind the tape" πŸ“Όβœ¨

πŸ™ˆ goto_item

Unlike goto_item in Jifty::DBI::Collection, Union only supports going to the first item in the collection.

yeah. it's a limited edition. only one destination. no cap.

πŸŽ€ is_last

Returns true if the current row is the last record in the set.

perfect for those "am I done yet" moments 😭

🫢 items_array_ref

Return a reference to an array containing all objects found by this search.

Will destroy any positional state. πŸ’€

so like, u get the whole array, but ur current position? gone. evaporated. consider urself warned πŸ™ˆ


🌟 AUTHOR 🌟

Copyright (c) 2004 Robert Spier

All rights reserved.

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

shoutout Robert Spier for this 2004 banger 🫢


πŸ¦‹ SEE ALSO πŸ¦‹

  • Jifty::DBI
  • Jifty::DBI::Collection

go read those too, they're the parents of this whole situation iykyk πŸ’–


and that's the page bestie!! perl v5.34.0, dated 2022-06-15, straight from the User Contributed Perl Documentation. slay, go union some collections πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from