ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:classhasmany

This is an old revision of the document!


classHasMany

Syntax
void ADODB_Active_Record::ClassHasMany(
  string $class, 
  string $relation, 
  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


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
}
v5/activerecord/classhasmany.1449327748.txt.gz · Last modified: 2017/04/21 11:21 (external edit)