Example #1
0
 /**
  * Returns column SQL identifier, performs autojoining!
  * @param string $name
  * @return string|bool Returns SQL identifier; FALSE if the column does not exists
  */
 protected function getColumnIdentifier($name)
 {
     if (($pos = \strpos($name, '.')) !== FALSE) {
         $relName = \substr($name, 0, $pos);
         $relations = $this->reflection->parents + $this->reflection->singles + $this->reflection->children;
         if (isset($relations[$relName])) {
             $name = substr($name, $pos + 1);
             //auto joining
             if (isset($this->joined[$relName])) {
                 $table = $this->joined[$relName];
             } else {
                 $table = new self($relations[$relName]);
                 $this->join($table, $relName);
             }
             $i = $table->getColumnIdentifier($name);
             if ($i !== FALSE) {
                 return $i;
             }
         }
         if (isset($this->extends)) {
             return $this->extends->getColumnIdentifier($name);
         }
         return FALSE;
     }
     $i = isset($this->reflection->columns[$name]) ? $this->reflection->columns[$name] : ($this->reflection->isColumn($name) ? $name : FALSE);
     if ($i !== FALSE) {
         return \implode('.', array($this->alias, $i));
     }
     if (isset($this->extends)) {
         return $this->extends->getColumnIdentifier($name);
     }
     return FALSE;
 }