|
From: Noten M. <mar...@te...> - 2006-12-19 12:25:14
|
Dear all,
my question is about how well WASP supports inheritance. WASP uses the PE=
AR DB_DataObject package and the DataObjectWrapper extends PEAR. Let's co=
nsider the following use case:
-- Table PERSON
create table person {
id mediumint not null auto_increment,
surname varchar(60),
forename varchar(60)
}
-- Table SALES_PERSON
-- A sales person is a person with an extra column number and superSalesP=
ersonId
create table sales_person {
id mediumint not null auto_increment,
number int not null,
personId not null,
superSalesPersonId mediumint,
-- 2 FK constraints...
}
I think we have to use the getLink() or getLinks() method from the PEAR D=
B_DataObject package like:
$person =3D $salesPerson->getLink('personId')
I think you can munually modify the SalesPersonWrapper class so that it e=
xtends from the PersonWrapper class. But how can I now create a new sales=
person from a form that contains surname, forname, number and superSales=
PersonId input fields?
$oPerson =3D new PersonWrapper();
$oPerson->fillFromRequest();
$oPerson->save();
$personId =3D $oPerson->getId();
$oSalesPerson =3D new SalesPersonWrapper();
$oSalesPerson->fillFromRequest();
// Make the inheritance link
$oSalesPerson->setPersonId($personId);
It would be nice if you could skip the first part of the code because the=
above code does not have any concept of inheritance.
Another question I have is about using more than one database? I think yo=
u have modify one of the db classes that makes the actual database connec=
tion so you can work with more than one database. I think I'm not the onl=
y one who needs this functionality so maybe somebody can post the needed =
PHP code.
Best regards,
Mark
|