/** * 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"); }