DBIx::...arison(3pm)

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

πŸ’– DBIx::Simple::Comparison πŸ’–

okay bestie, welcome to the DBIx::...arison page β€” it's a User Contributed Perl Documentation joint, and it's literally just a cheat-sheet for translating between DBIx::Simple and raw DBI. pull up a chair. 🫢


✨ NAME ✨

DBIx::Simple::Comparison β€” DBIx::Simple in DBI jargon. that's it, that's the whole vibe. πŸ’…


🌸 DESCRIPTION 🌸

so this is just a simple and inaccurate overview of what DBI things the DBIx::Simple things represent β€” or the other way around, we're not picky. πŸ™ˆ

it's here to help you find the foo equivalent of bar. iykyk. πŸ¦‹

here's the legend, bestie, memorize it:

  • ? means DBI doesn't have an equivalent, or the author genuinely couldn't find one. no cap.
  • = means DBIx::Simple is giving direct wrapper β€” it just hands the thing straight to the DBI function. periodt.
  • ~ means DBIx::Simple's method does more or less the same thing, but usually in a more high-level way: context sensitive, combining stuff, automatically taking care of something. it's doing the most, lovingly. ✨
πŸ’€ important reality check: DBIx::Simple is a wrapper around DBI. it is not "better" than DBI. in fact, DBIx::Simple literally cannot work without DBI. they're a package deal.

also: using DBI directly is always faster than using DBIx::Simple's equivalents. (for the computer, that is. for you, DBIx::Simple is supposed to be faster.) 😭


πŸ‘‘ Classes, common names πŸ‘‘

use DBI       ~  use DBIx::Simple

$DBI::errstr  =  DBIx::Simple->error

DBI::db       ~  DBIx::Simple
$dbh          ~  $db
$dbh->errstr  =  $db->error

connect       ~  connect
connect       ~  new

DBI::st       ~  DBIx::Simple::Result
<undef>       ~  DBIx::Simple::Dummy
$sth          ~  $result

🌈 Queries 🌈

DBI be like:

my $sth = $dbh->prepare_cached($query);
$sth->execute(@values);

~ DBIx::Simple be like:

my $result = $db->query($query, $values);

look at that glow-up. one line. iconic. πŸŽ€


πŸ¦‹ Results πŸ¦‹

DBI                          DBIx::Simple

bind_columns              ~  bind

fetchrow_arrayref/fetch   =  fetch
fetchrow_array            ~  list
*1                        ~  flat
[@{fetchrow_arrayref}]    =  array
fetchall_arrayref         ~  arrays
fetchrow_hashref() *2*3   =  hash
fetchall_arrayref({}) *4  ~  hashes

fetchall_hashref *2       =  map_hashes
?                         ?  map_arrays
fetchall_hashref(1) *2    =  map

$sth->{NAME_lc/NAME}      =  $result->columns

and now the footnotes, because of course there are footnotes, bestie πŸ“:

  • *1 There's no fetch variant, but you can do { @{ $dbh->selectcol_arrayref('SELECT ...', { Slice => [] }) } }.
  • *2 To receive the keys (column names) lowercased, use $db->{FetchHashKeyName} = 'NAME_lc'. DBIx::Simple lower cases them by default. it just does. 🫢
  • *3 Or supply an argument, 'NAME_lc'.
  • *4 No, arrayref isn't a typo. When supplied an empty hash reference, DBI's fetchall_arrayref actually returns hashrefs. This DBI method does not support lower casing of keys, DBIx::Simple does.

πŸ’œ Direct access πŸ’œ

DBI                 DBIx::Simple

$dbh             =  $db->dbh
$sth->{$foo}     =  $result->attr($foo)

func             =  func

begin_work       =  begin_work
commit           =  commit
rollback         =  rollback
last_insert_id   =  last_insert_id
rows             =  rows

disconnect       ~  disconnect
finish           ~  finish

🧚 DBIx::Simple specific (?) 🧚

these are the little extras DBIx::Simple brings to the group chat β€” the question mark is right there in the heading, don't @ me:

keep_statements
lc_columns
iquery (via SQL::Interp)
select, insert, update, delete (via SQL::Abstract)
abstract (via SQL::Abstract)
flat
hashes
map_arrays
map

🌟 AUTHOR 🌟

Juerd Waalboer <juerd@cpan.org> <http://juerd.nl/> β€” shoutout, absolute legend. πŸ‘‘


πŸ’« SEE ALSO πŸ’«

DBI, DBIx::Simple β€” go read those next, bestie, they're the main characters. πŸ”₯


okay that's the whole page, mwah πŸ’‹ β€” this was perl v5.36.0, dated 2023-09-01, and it's User Contributed Perl Documentation, so go forth and query responsibly. slay. πŸ’–βœ¨

πŸ“¦ where this page comes from