57 private function _init($class, $annot) {
59 $this->targetEntity = $annot [
"targetEntity"];
60 $this->inversedBy = lcfirst ( $this->targetEntity ) .
"s";
61 if (! is_null ( $annot [
"inversedBy"] ))
62 $this->inversedBy = $annot [
"inversedBy"];
63 $this->targetEntityClass = get_class (
new $this->targetEntity () );
66 $this->joinTable = $annotJoinTable [
"name"];
70 if (isset ( $annotJoinTable [
"joinColumns"] )) {
71 $joinColumnsAnnot = $annotJoinTable [
"joinColumns"];
72 if (! is_null ( $joinColumnsAnnot )) {
73 $this->myFkField = $joinColumnsAnnot [
"name"];
74 $this->myPk = $joinColumnsAnnot [
"referencedColumnName"];
80 if (isset ( $annotJoinTable [
"inverseJoinColumns"] )) {
81 $inverseJoinColumnsAnnot = $annotJoinTable [
"inverseJoinColumns"];
82 if (! is_null ( $inverseJoinColumnsAnnot )) {
83 $this->fkField = $inverseJoinColumnsAnnot [
"name"];
84 $this->pk = $inverseJoinColumnsAnnot [
"referencedColumnName"];
188 public function getSQL($alias =
"", $aliases =
null) {
189 $quote = $this->db->quote;
192 $alias = $quote . $alias . $quote;
196 $jtAlias = uniqid ( $this->joinTable );
198 if (is_array ( $aliases )) {
199 if (isset ( $aliases [$this->table] ))
202 return " INNER JOIN {$quote}" . $this->joinTable .
"{$quote} {$quote}{$jtAlias}{$quote} on {$quote}" . $jtAlias .
"{$quote}.{$quote}" . $this->myFkField .
"{$quote}={$quote}" .
$table .
"{$quote}.{$quote}" . $this->myPk . $quote .
" INNER JOIN {$quote}" . $this->targetEntityTable .
"{$quote} {$alias} on {$quote}" . $jtAlias .
"{$quote}.{$quote}" . $this->fkField .
"{$quote}={$quote}" .
$targetEntityTable .
"{$quote}.{$quote}" . $this->pk . $quote;