Dancer::Plugin::Database 1.10 - bugfixes and quick_select()

Over the weekend I released Dancer::Plugin::Database 1.10, incorporating a couple of bug fixes thanks to Christian Sanchez, Michael Stiller and crayon.

I've also added a quick_select feature; it seemed odd to not have it since quick_insert, quick_update and quick_delete were all provided.

It lets you do simple queries very quickly:

# In scalar context, returns first matching row as a hashref:
my $user = database->quick_select('users', { id => $user_id });
return "Hello there, " . $user->{first_name};

# In list context, returns all matching rows as hashrefs:
my @users = database->quick_select('users', { category => 'admin' });

It's intended for simple queries, so if you need to retrieve only certain columns, sort results, do joins etc; since the database keyword gives you a normal DBI handle, you can just do it however you like. For simple queries, you might enjoy the simplicity, though.

Leave a comment

About David Precious

user-pic Professional Perl developer, Dancer core team member, beer drinker. See http://www.preshweb.co.uk/about for more :)