Class::DBI::Query(3)
β¨ Class::DBI::Query(3) β¨
okay so real talk, bestie β this is a page from Class::DBI::Query, part of the User Contributed Perl Documentation crew, and the very first thing you need to know is right in the title: it's deprecated. Like, this is the old SQL manager for Class::DBI. It's been sidelined. Still iconic in its day though π
π NAME π
Class::DBI::Query β Deprecated SQL manager for Class::DBI. That's it. That's the whole name. She's a legacy queen and we respect her π
β SYNOPSIS β
Here's the whole vibe in code, no notes:
my $sth = Class::DBI::Query
->new({
owner => $class,
sqlname => $type,
essential => \@columns,
where_columns => \@where_cols,
})
->run($val);
look at her go π new it up with a hashref, then run it with your value. slay.
π DESCRIPTION π
So what does this thing do? It abstracts away a whole bunch of the messy little details of the SQL mechanism that lives underneath Class::DBI. Basically it's the middle manager of your queries π«Ά
ngl though β for the most part, you probably don't want to be interfacing directly with this. Like, it's behind the curtain for a reason, bestie. Let the framework handle it π
β οΈ heads up! The underlying mechanisms are not yet stable, and are subject to change at any time. That's not me being dramatic, that's literally what the docs say. So don't build your whole personality around this API, okay? π
πΈ OPTIONS πΈ
A Query can have many options set before executing. Most of them can either be passed as an option to new(), or set later if you're building the query up dynamically β which is honestly such a flex, you can just keep adding to her as you go π¦
π owner
The Class::DBI subclass that 'owns' this query. In the vast majority of cases a query will return objects β and the owner is the class of which instances will be returned. So like, the owner is the vibe, the objects are the guest list π
π§ sqlname
This should be the name of a query set up using set_sql. That's it. That's the whole thing. iykyk β¨
π where_clause
This is the raw SQL that will be substituted into the 'WHERE %s' in your query. If you've got multiple %s's in your query, then you should supply a listref of where_clauses β one for each, no skipping, bestie π
This SQL can also include placeholders, which will be used when you call run(). Cute, right? π
π essential
When retrieving rows from the database that match the WHERE clause of the query, these are the columns that we fetch back and pre-load the resulting objects with. Obsessed with pre-loading honestly, it's giving efficiency π
By default, this is the Essential column group of the owner class. defaults are a gift π«Ά
π₯ METHODS π₯
β where()
$query->where($match, @columns);
This will extend your 'WHERE' clause by adding a 'AND $column = ?' (or whatever $match is, instead of "=") for each column you pass in. So like, one chunk per column, add 'em all, go off π
And if you've got multiple WHERE clauses? This will extend the last one. not the first, not the middle β the last. don't forget it or you'll be confused for an hour, trust me π
and that's the whole page, bestie! go forth and query responsibly πΈπ
with love, from the perl v5.42.0 girlies β dated a very vintage 2011-04-08 π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Class-DBI 3.0.17-bp160.1.10 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms