コード例 #1
0
ファイル: Relation.php プロジェクト: sigma-z/dive
 /**
  * @param Record $record
  * @param string $relationName
  * @return array
  * @throws RelationException
  */
 public function getOriginalReferencedIds(Record $record, $relationName)
 {
     $isReferencedSide = $this->isReferencedSide($relationName);
     if ($isReferencedSide) {
         $owningField = $this->getOwningField();
         if ($record->isFieldModified($owningField)) {
             return array($record->getModifiedFieldValue($owningField));
         }
         return array($record->get($owningField));
     }
     $query = $this->getReferenceQuery($record, $relationName, array($record->getInternalId()));
     $originalReferencedIds = $query->fetchScalars();
     if ($this->isOneToOne()) {
         $moreThanOne = isset($originalReferencedIds[1]);
         if ($moreThanOne) {
             throw new RelationException("One-to-one relation has returned more than one result!");
         }
     }
     return $originalReferencedIds;
 }