I have been playing around with Class::DBI to see why
everyone loves it so much and I cannot figure it out. You
have to set up your own database and tables. Then you have
to tell the class about your table and it's structure.
Then, you have to learn the class's new syntax for dealing
with a relational database which is less flexible than the
SQL which you must already know since you had to set up your
own table in the first place!
The only benefit I can see is that you can move your code to
different databases without change, but I would prefer a
solution that abstracts the database interaction completely
where you can design forms and modify them and the database
will shape itself to fit the forms.
As far as telling Class::DBI about the database structure, I
don't understand why. It seems fairly easy with DBI
functions to have a program read database structure itself.
Here is a script that reads the entire structure of all of
my databases:
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
my $dbh = DBI->connect
("DBI:mysql:host=localhost;database=mysql", "", "",
{PrintError
=> 0, RaiseError => 1});
my $dblist = $dbh->selectcol_arrayref("show databases");
my %databases;
for(@$dblist)
{
$dbh->do("use $_");
my $tables = $dbh->selectcol_arrayref("show tables");
my @full_table_data;
for (@$tables)
{
my $columns = $dbh->selectcol_arrayref
("describe $_");
push @full_table_data, [ ($_, @$columns) ];
}
$databases{$_} = [ @full_table_data ];
}
use Data::Dumper;
print Dumper(%databases);
I am not putting down the module. It's just that if so many
professionals feel that it is a good tool, I just wanted to
understand why.
Thank you,
Mark
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]