August 2006 Archives

I wrote something about SQL::Abstract in this recent article, so I will now show the features of a small module which works perfectly well with the above mentioned one, but also without it: DBIx::Simple. This package provides a nicer interface to DBI, and allows to use SQL::Abstract to build queries (but does not require it).

DBI works just fine, but it sometimes gets boring to write the code which uses it: most of time you have to prepare_cached your query and then execute it; to retrieve the data you have to use fetchall_arrayref or one of the similar long-named methods, often passing them the needed parameters. DBIx::Simple makes all of this... simpler. For example, if you need to fetch some rows into an hashref you just write:

use DBIx::Simple;

my $db = DBIx::Simple->new(
    'dbi:mysql:database=mydb;host=myhost', 'myuser', 'mypass'

my $res = $db->query(
    'select id, username, address from users where role = ?',

my $rows = $res->hashes;

About this Archive

This page is an archive of entries from August 2006 listed from newest to oldest.

July 2006 is the previous archive.

September 2006 is the next archive.

Find recent content on the main index or look in the archives to find all content.



OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.14-en