Class:...Search(3pm)

πŸ“¦
version 0.07 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Class::DBI::AbstractSearch β€” the Class:...Search(3pm) glow-up πŸ’–

okay bestie, gather round, because this one is a manual page for Class::DBI::AbstractSearch, and it's literally the moment your Class::DBI setup gets a whole personality. it's giving "abstract Class::DBI's SQL with SQL::Abstract::Limit" energy, and honestly? obsessed. πŸ¦‹


✨ NAME ✨

Class::DBI::AbstractSearch β€” abstract Class::DBI's SQL with SQL::Abstract::Limit. that's the whole vibe. no cap.


🌸 SYNOPSIS 🌸

here's the moment you've been waiting for, the main character entrance:

  package CD::Music;
  use Class::DBI::AbstractSearch;

  package main;
  my @music = CD::Music->search_where(
      artist => [ 'Ozzy', 'Kelly' ],
      status => { '!=', 'outdated' },
  );

  my @misc = CD::Music->search_where(
      { artist => [ 'Ozzy', 'Kelly' ],
        status => { '!=', 'outdated' } },
      { order_by      => "reldate DESC",
        limit_dialect => 'LimitOffset',
        limit         => 1
        offset        => 2 });

look at her go. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so like, Class::DBI::AbstractSearch is a Class::DBI plugin, right? and its whole job β€” its purpose, its calling, its moment β€” is to glue SQL::Abstract::Limit into Class::DBI. that's it. that's the slay. πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

using this module adds the following methods into your data class. yes, your data class. it's giving generous. 🫢

🌈 search_where

  $class->search_where(%where);

takes a hash to specify the WHERE clause. for the hash options, go look at SQL::Abstract, bestie β€” that's where the deets live.

  $class->search_where(\%where,\%attrs);

takes a hash reference to specify the WHERE clause. again, see SQL::Abstract for the hash options. and then it takes a hash reference to specify additional query attributes. here's the tea on which attributes Class::DBI::AbstractSearch actually uses:

  • order_by β€” an array reference of fields that will be used to order the results of your query. lineup time. ✨
  • limit_dialect β€” a scalar, DBI handle, object class, etc. that describes the syntax model for a LIMIT/OFFSET SQL clause. please see SQL::Abstract::Limit for more information, i'm not gonna gatekeep but i'm also not gonna re-explain it. πŸ™ˆ
  • limit β€” a scalar value that will be used for the LIMIT argument in a query. keeping it contained, periodt.
  • offset β€” a scalar value that will be used for the OFFSET argument in a query. the little scoot. πŸŽ€

any other attributes are passed to the SQL::Abstract::Limit constructor, and can be used to control how queries are created. for example, to use 'AND' instead of 'OR' by default, use:

  $class->search_where(\%where, { logic => 'AND' });

lowkey iconic that it just hands the rest over like that. πŸ’œ


πŸ’… AUTHOR πŸ’…

Tatsuhiko Miyagawa <miyagawa@bulknews.net> β€” with some help from the cdbi-talk mailing list, especially:

  Tim Bunce
  Simon Wilcox
  Tony Bowden

and listen: this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go off. legally. 🌸


πŸ¦‹ SEE ALSO πŸ¦‹

  • Class::DBI
  • SQL::Abstract
  • SQL::Abstract::Limit

bestie reminder: this page ships as part of perl v5.32.0, dated 2021-01-01, and it's a User Contributed Perl Documentation page for Class:...Search(3pm). okay love u bye πŸ’–βœ¨πŸŽ€
πŸ“¦ where this page comes from