Overview

Namespaces

  • Alchemy
    • core
      • query
      • schema
    • dialect
    • engine
    • orm
    • tests
    • util
      • promise
  • PHP

Classes

  • DataMapper
  • DDL
  • ManyToOne
  • OneToMany
  • OneToOne
  • ORMQuery
  • ORMTable
  • ORMTableRef
  • RelatedSet
  • Relationship
  • Session
  • SessionSelect
  • WorkQueue
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace  Alchemy\orm;
 4: 
 5: 
 6: class OneToOne extends Relationship {
 7: 
 8:     /**
 9:      * Return true if the origin of this relationship is the source of
10:      * foreign key index. False if the source of the foreign key is the
11:      * destination of this relationship
12:      *
13:      * @return bool
14:      */
15:     public function isParent() {
16:         return $this->origin === $this->getForeignKey()->getSourceTable();
17:     }
18: 
19: 
20:     public function getRemoteColumnMap($origin) {
21:         $map = $this->getForeignKey()->getNameMap();
22:         $map = $this->isParent() ? array_flip($map) : $map;
23: 
24:         foreach ($map as $remote => &$local) {
25:             $local = $origin->{$local};
26:         }
27: 
28:         return $map;
29:     }
30: 
31: 
32:     public function set($origin, $remote) {
33:         $this->assertDestinationType($remote);
34: 
35:         return $this->isParent()
36:             ? $origin->cascadeForeignKey($remote, $this)
37:             : $remote->cascadeForeignKey($origin, $this->getInverse());
38:     }
39: }
40: 
API documentation generated by ApiGen 2.8.0