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
In reply to Re: Beginner OOP style question
by Zaxo
in thread Beginner OOP style question
by Tardis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |