bigpresh/Dancer-Plugin-Database — Issue #23: New features in ::Handle
Author: knutov
Created: 2012-01-28 01:49:35+00:00
State: open

Please take a look at knutov/Dancer-Plugin-Database@fa6acf55096079d436228643696b5362bb337c26

I'm trying to finally move from my own framework (which is obsolete enough now) to Dancer. I used my own module to handle MySQL queries but now I want to switch to D::P::Database - it's great, more universal and can work if threads used. So I have to port some very convenient features from my framework and did it in this commit.

What do you think about it?
Is it ok to extend this module (I will add logging support and tests before pull request later) or it's better to move them to another module? If so, can you add support of adding new handles? Something like

```perl
bless $dbh, $_ foreach @handles; return 1;
```
instead of

```perl
return bless $dbh, 'Dancer::Plugin::Database::Handle';
```
in `D::P::Database.pm`

(I think support of multiple handles will be great anyway)

Example of usage of new features:

```perl
use Data::Dumper;
...

get '/' => sub {
debug Dumper(database->sql('select * from users')); debug '---';
debug Dumper(database->select('select * from users where id=?',1)); debug '---';
debug database->cnt('select * from users where id=?',1); debug '---';
debug Dumper(database->row('select * from users where id=1')); debug '---';
my ($a,$b) = database->row('select * from users where id=1');
debug "$a, $b"; debug '---';
debug database->insert('insert into users (name) values (?)','123'); debug '---';
return database->cnt('select * from users where id=?',1);
};
```