public function getProjection(Sabel_Db_Statement $stmt) { $projection = array(); $name = $this->hasAlias() ? strtolower($this->aliasName) : $this->tblName; foreach ($this->columns as $column) { $as = "{$name}.{$column}"; if (strlen($as) > 30) { $as = Sabel_Db_Join_ColumnHash::toHash($as); } $p = $stmt->quoteIdentifier($name) . "." . $stmt->quoteIdentifier($column); $projection[] = $p . " AS " . $stmt->quoteIdentifier($as); } return $projection; }
protected function createProjection(Sabel_Db_Statement $stmt) { if (empty($this->projection)) { $projection = array(); foreach ($this->objects as $object) { $projection = array_merge($projection, $object->getProjection($stmt)); } $quotedTblName = $stmt->quoteIdentifier($this->tblName); foreach ($this->model->getColumnNames() as $column) { $projection[] = $quotedTblName . "." . $stmt->quoteIdentifier($column); } } else { $projection = array(); foreach ($this->projection as $name => $proj) { if (($tblName = convert_to_tablename($name)) === $this->tblName) { foreach ($proj as $column) { $projection[] = $stmt->quoteIdentifier($tblName) . "." . $stmt->quoteIdentifier($column); } } else { foreach ($proj as $column) { $as = "{$tblName}.{$column}"; if (strlen($as) > 30) { $as = Sabel_Db_Join_ColumnHash::toHash($as); } $p = $stmt->quoteIdentifier($tblName) . "." . $stmt->quoteIdentifier($column); $projection[] = $p . " AS " . $stmt->quoteIdentifier($as); } } } } return implode(", ", $projection); }