in reply to Beginner OOP style question
Your database is a persistent collection of Persons. It is not a Person, but it needs knowlege of a Person's data. One stylish way to do that is to name its columns after a Person's accessor methods. A Person constructor can be designed to initialize directly from a single record in the database. Example:
which obtains an array of potential Betty Persons from an SQL statement with knowlege of what data array can construct a Person, and a single placeholder for given neames. The OOP model is that the database is a persistent store of a collection of Person objects.my $gnsth = $dbi->prepare $sqlthing; my @bettys = map {Person->new($_)} @{$gnsth->fetchall_arrayref('Elizabeth')};
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Beginner OOP style question
by thpfft (Chaplain) on Mar 02, 2002 at 16:47 UTC |