The TableRecord class describes one record from a Table.
Connect the 1-side of a Relation to another record
$thisTableRecord = TableRecordFactory::getTableRecord( 'myTable', $idTableRecord1 ); $otherTableRecord = TableRecordFactory::getTableRecord( 'myOtherTable', $idTableRecord2 ); $thisTableRecord->set( 'theRelationField', $otherTableRecord->getUUID() );
Connect the 1-side of a multiRelation to another record specifying which relation to set
$thisTableRecord = TableRecordFactory::getTableRecord( 'myTable', $idTableRecord1 ); $otherTableRecord = TableRecordFactory::getTableRecord( 'myOtherTable', $idTableRecord2 ); $thisTableRecord->set( 'theRelationField', "relationname;".$otherTableRecord->getUUID() );
alternatively
$thisTableRecord = TableRecordFactory::getTableRecord( 'myTable', $idTableRecord1 ); $otherTableRecord = TableRecordFactory::getTableRecord( 'myOtherTable', $idTableRecord2 ); $thisTableRecord->getField( 'theRelationField' )->setActiveRelation( "relationname" ); $thisTableRecord->set( 'theRelationField', $otherTableRecord->getUUID() );
Connect the X-side of a Relation to another record
$thisTableRecord = TableRecordFactory::getTableRecord( 'myTable', $idTableRecord1 ); $otherTableRecord = TableRecordFactory::getTableRecord( 'myOtherTable', $idTableRecord2 ); $thisTableRecord->setRelation( 'relationName', $otherTableRecord->getUUID() );
Set a value to a field in the record
$tableRecord->set( 'field', $value );