====== classHasMany ======
~~NOTOC~~
== Syntax ==
void ADODB_Active_Record::classHasMany(
string $parentTable,
string $childTable,
optional string $foreignKey = '',
optional string $foreignClass = 'ADODB_Active_Record'
)
------------------------------
===== Description =====
Globally defines a one-to-many relationship. Once defined, the relationship persists for the life of the script.
===== Parameters =====
==== $parentTable ====
The parent table in the relationship
==== $childTable ====
The child table in the relationship
==== $foreignKey ====
If, due to database design constraints, the key field in the child table is not named the same as that of the parent table, specify it here.
==== $foreignClass ====
If the class name for the child table differs from that of the parent, for example there has been some extension of methods, specify it here
-------------------------
===== Usage =====
class person extends ADOdb_Active_Record{}
ADODB_Active_Record::ClassHasMany('person', 'children','person_id');
$person = new person();
$person->Load("id=1");
foreach($person->children as $c) {
echo " $c->name_first ";
$c->name_first .= ' K.';
$c->Save(); ## each child record must be saved individually
}