/** * Returns the string representation of this relationship * @param $query Query - the source of the relationship * @return string - string representation */ function toString($query) { $joinString = ""; // If the relationship is mandatory, enforce this using an INNER JOIN if ($this->mandatory) { $joinString = "INNER JOIN "; } else { $joinString = "LEFT OUTER JOIN "; } if ($this->type == RelationShip::OneToManyType()) { $string = ""; $string = $string . $joinString . "##" . $this->query->getClassName() . " ON"; $string = $string . " ##" . $query->getClassName() . ".ID = ##" . $this->query->getClassName() . "." . $query->getClassName() . "ID"; return $string; } if ($this->type == RelationShip::ManyToOneType()) { $string = ""; $string = $string . $joinString . "##" . $this->query->getClassName() . " ON"; $string = $string . " ##" . $this->query->getClassName() . ".ID = ##" . $query->getClassName() . "." . $this->query->getClassName() . "ID"; return $string; } trigger_error("The relationship type " . $this->type . " is unknown"); }
/** * new HasMany('order', array('entityType' => 'Order', 'entityColumn' => 'orderid', 'ReadByMethod' => 'find_all_by_orderid'); * * @param unknown_type $property * @param unknown_type $config */ public function __construct($property, $config) { parent::__construct($property, $config); $method = 'find_all_by_' . $this->getEntityColumn(); if (isset($config['loadByMethod'])) { $this->isCustomLoadMethod = true; $method = $config['loadByMethod']; } $this->setLoadByMethod($method); }
protected function addRelationShip(RelationShip $relation) { $this->relationShips[$relation->getProperty()] = $relation; }