예제 #1
0
 /**
  * Remove Other One-to-One
  * Removes other relationships on a one-to-one ITFK relationship
  *
  * @ignore
  * @param string $rf Related field to look at.
  * @param DataMapper $object Object to look at.
  */
 private function _remove_other_one_to_one($rf, $object)
 {
     if (!$object->exists()) {
         return;
     }
     $related_properties = $this->_get_related_properties($rf, TRUE);
     if (!array_key_exists($related_properties['other_field'], $object->has_one)) {
         return;
     }
     // This should be a one-to-one relationship with an ITFK if we got this far.
     $other_column = $related_properties['join_other_as'] . '_id';
     $c = get_class($this);
     $update = new $c();
     $update->where($other_column, $object->id);
     if ($this->exists()) {
         $update->where('id <>', $this->id);
     }
     $update->update($other_column, NULL);
 }
예제 #2
0
 /**
  * Check model for existence and throw NotFoundException exception
  *
  * @param DataMapper $model
  * @param string $message
  */
 protected function throwModelNotFoundException(\DataMapper $model, $message = 'Resource not found!')
 {
     if (!$model->exists()) {
         $this->throwNotFoundException($message);
     }
 }