Perl MySQL OO design question

2001-09-10 Thread Richard Reina

I have a perl-DBI-MySQL database app. that handles everything from my 
order entry to my accounts payable.  I am in the process of cleaning up 
a lot of the code I've written to make it easier to maintain.  I 
probably use the following DBI staement handle about fifty different 
places on different tables:

use DBI;
my $dbh = 
DBI-connect(DBI:mysql:database=operations;192.128.0.1,abuser,whisky);
my $q = INSERT into table (column, column, column, column) VALUES (?, 
?, ?, ?);
my $sth = $dbh-prepare($q);
$sth-execute($val1, $val2, $val3, $val4);

Would it be best to create a class called INSERT that all scripts call 
when they need to insert create a new record in a table?

Richard


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [Chicago.pm]: Perl MySQL OO design question

2001-09-10 Thread Andy Lester

 I have a perl-DBI-MySQL database app. that handles everything from my
 order entry to my accounts payable.  I am in the process of cleaning up
 a lot of the code I've written to make it easier to maintain.  I
 probably use the following DBI staement handle about fifty different
 places on different tables:

If you've got the same SQL getting executed over 'n' over, you can just
keep the same $sth and re-execute each time.  For instance.

 DBI-connect(DBI:mysql:database=operations;192.128.0.1,abuser,whisky);
 my $q = INSERT into table (column, column, column, column) VALUES (?,
 ?, ?, ?);
 my $sth = $dbh-prepare($q);
 $sth-execute($val1, $val2, $val3, $val4);

And then:

$sth-execute(@another_set_of_vals);
$sth-execute(still,more,values,here);

etc etc

with appropriate error checking, natch.

xoxo,
Andy

-- 
%_=split/;/,.;;n;u;e;ot;t;her;c; .   #   Andy Lester
'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
hack;print map delete$_{$_},split//,q   [EMAIL PROTECTED]   



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php