DBIx::...wObject(3pm)

πŸ“¦
version 1.37 Β· 6 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

DBIx::Simple::Result::RowObject β€” bestie, it's the Simple result row object class. That's it, that's the name ✨


🌸 DESCRIPTION 🌸

okay so this class is the default for the "object" and "objects" result object methods. What does it actually do? Mainly it hands you syntactic sugar β€” and the price tag is performance. Yeah. Sugar costs, no cap 😭

Instead of writing this whole thing:

my $r = $db->query('SELECT foo, bar FROM baz')->hash;
do_something_with $r->{foo}, $r->{bar};

you may write:

my $r = $db->query('SELECT foo, bar FROM baz')->object;
do_something_with $r->foo, $r->bar;

see how much cuter that is?? dots instead of curlies, the way that $r->foo just hits different πŸ’…

This class is a subclass of Object::Accessor, which is the icon that gives you per-object accessors (not per-class β€” per-object, okay, that distinction matters). And because of that, your records must not have column names like these:

  • can
  • ls_accessors
  • ls_allow
  • mk_accessor
  • mk_clone
  • mk_flush
  • mk_verify
  • new
  • register_callback
  • ___autoload
  • ___callback
  • ___debug
  • ___error
  • ___get
  • ___set

And of course DESTROY and AUTOLOAD, and anything that new versions of Object::Accessor might add. like, the list is not closed, bestie, it can grow πŸ™ˆ so just… don't name your columns after methods. vibe check failed otherwise.

⚠️ fr fr: name a column one of these and things get weird. this is not a drill.

πŸ¦‹ DBIx::Simple::OO πŸ¦‹

DBIx::Simple::OO is a third party module by Jos Boumans that provided "object" and "objects" to DBIx::Simple. Similar functionality is now built in, in part inspired by DBIx::Simple:OO. (yes, that colon is in the original, i'm not touching it, i keep every detail periodt πŸ’–)

Using DBIx::Simple 1.33 or newer together with DBIx::Simple::OO 0.01 will result in a method name clash. 😭 DBIx::Simple::Result::RowObject was written to be compatible with DBIx::Simple::OO::Item, except for the name, so "isa" calls still need to be changed. yeah. the name. it's different. that's the whole thing.

In practice, DBIx::Simple 1.33 makes DBIx::Simple::OO obsolete. ✨ rest in peace legend, you served 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Juerd Waalboer <juerd@cpan.org> <http://juerd.nl/> β€” icon behavior, we stan 🌈


🌟 SEE ALSO 🌟

  • DBIx::Simple β€” the main character, go read it πŸ’œ

this page is from the User Contributed Perl Documentation, perl v5.36.0, dated 2023-09-01, and it's DBIx::...wObject(3pm) β€” mwah, thanks for reading bestie, go forth and ->object responsibly πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from