DBI-Mysqlsimple reviews

cpanratings
 

RSS | Module Info | Add a review of DBI-Mysqlsimple

DBI-Mysqlsimple (0.02) *

I agree with the previous reviewer. IMO, overall this module is not necessary. Plain DBI is actually simple enough for simple cases. Maybe the author of Mysqlsimple did not realize this. Let's compare:

* Retrieving a single row:
Mysqlsimple: my ($v1,$v2) = $db->get_row("select v1,v2 from table");
DBI: my ($v1, $v2) = $dbh->selectrow_array("select v1,v2 from table");

* Retrieving a single row (with params):
Mysqlsimple: my ($v1,$v2) = $db->get_row("select v1,v2 from table where cond1=? and cond2=?", [$cond1,$cond2]);
DBI: my ($v1,$v2) = $db->selectrow_array("select v1,v2 from table where cond1=? and cond2=?", {}, $cond1,$cond2);

* Retrieving all rows with params:
Mysqlsimple: my $rows = $db->get_rows(..., [$param1, $param2]);
DBI: my $rows = $dbh->selectall_arrayref(..., {}, $param1, $param2);

* do() with params:
Mysqlsimple: my $rows = $db->do(..., [$param1, $param2]);
DBI: my $rows = $dbh->do(..., {}, $param1, $param2);

As you can see, the differences are minimal.

DBI-Mysqlsimple (0.02) *

Should be in DBIx

Mysqlsimple is also a very bad name space

re-implements do() and disconnect() (chance for behavioral changes)

makes it more complicated to do use dbh object methods

no way to make queries efficent by:

- reusing statement handles

- going though multiple records one at a time instead of slurping them all into memory first

Also a point of complexity and confusion:

get_row (singular) returns an array (possibly plural)

get_rows (plural) returns one item (singular)

it makes sense to return that type of data for tha ttype of requestt and the method names make sense (as long as you speak english) but its not something intuitive, you have to consult the docs every time you want to use this.

So its simple in the fact that it has a few basic shortcut methods (that are already in DBI) but its actually more complex for the reasons outlined above.