v5:activerecord:tablekeybelongsto
This is an old revision of the document!
tableKeyBelongsTo
Syntax
void ADODB_Active_Record::tableKeyBelongsTo( string $childTable, string $childKey, string $relationName, string $foreignKey, string $parentPrimaryKey = 'id', string $parentClass = 'ADODB_Active_Record' )
Description
If the child table differs from the convention that the child table name is the plural of the child class name or the primary key is not 'id', use this function: ADODB_Active_Record::TableKeyBelongsTo()
Usage
In this example, the class is child
, but the table name is children
, the primary key is ch_id and the link between the two tables is children.person_id = person.id:
ADODB_Active_Record::TableKeyBelongsTo('children','ch_id', 'person','person_id','id');
v5/activerecord/tablekeybelongsto.1449325176.txt.gz · Last modified: 2017/04/21 11:20 (external edit)