/** * Adds a JOIN clause to the query * Infers the ON clause from a relation name * Uses the Propel table maps, based on the schema, to guess the related columns * Beware that the default JOIN operator is INNER JOIN, while Criteria defaults to WHERE * Examples: * <code> * $c->join('Book.Author'); * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::INNER_JOIN); * $c->join('Book.Author', Criteria::RIGHT_JOIN); * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::RIGHT_JOIN); * $c->join('Book.Author a', Criteria::RIGHT_JOIN); * => $c->addAlias('a', AuthorPeer::TABLE_NAME); * => $c->addJoin(BookPeer::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN); * </code> * * @param string $relation Relation to use for the join * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ModelCriteria The current object, for fluid interface * * @throws PropelException */ public function join($relation, $joinType = Criteria::INNER_JOIN) { // relation looks like '$leftName.$relationName $relationAlias' list($fullName, $relationAlias) = self::getClassAndAlias($relation); if (strpos($fullName, '.') === false) { // simple relation name, refers to the current table $leftName = $this->getModelAliasOrName(); $relationName = $fullName; $previousJoin = $this->getPreviousJoin(); $tableMap = $this->getTableMap(); } else { list($leftName, $relationName) = explode('.', $fullName); // find the TableMap for the left table using the $leftName if ($leftName == $this->getModelAliasOrName()) { $previousJoin = $this->getPreviousJoin(); $tableMap = $this->getTableMap(); } elseif (isset($this->joins[$leftName])) { $previousJoin = $this->joins[$leftName]; $tableMap = $previousJoin->getTableMap(); } else { throw new PropelException('Unknown table or alias ' . $leftName); } } $leftTableAlias = isset($this->aliases[$leftName]) ? $leftName : null; // find the RelationMap in the TableMap using the $relationName if (!$tableMap->hasRelation($relationName)) { throw new PropelException('Unknown relation ' . $relationName . ' on the ' . $leftName . ' table'); } $relationMap = $tableMap->getRelation($relationName); // create a ModelJoin object for this join $join = new ModelJoin(); $join->setJoinType($joinType); if (null !== $previousJoin) { $join->setPreviousJoin($previousJoin); } $join->setRelationMap($relationMap, $leftTableAlias, $relationAlias); // add the ModelJoin to the current object if ($relationAlias !== null) { $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { $this->addJoinObject($join, $relationName); } return $this; }
/** * Adds a JOIN clause to the query using the Product relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return OrganizationProductQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Product'); // create a ModelJoin object for this join $join = new ModelJoin(); $join->setJoinType($joinType); $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); if ($previousJoin = $this->getPreviousJoin()) { $join->setPreviousJoin($previousJoin); } // add the ModelJoin to the current object if ($relationAlias) { $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { $this->addJoinObject($join, 'Product'); } return $this; }
/** * PropelFormatter pour la requete sql directe * * @return PropelFormatter pour le requete getGroupe */ private static function getGroupeFormatter() { if (UtilisateurProfessionnel::$groupeFormatter === null) { $formatter = new PropelObjectFormatter(); $formatter->setDbName(GroupePeer::DATABASE_NAME); $formatter->setClass('Groupe'); $formatter->setPeer('GroupePeer'); $formatter->setAsColumns(array()); $formatter->setHasLimit(false); $groupeTableMap = Propel::getDatabaseMap(GroupePeer::DATABASE_NAME)->getTableByPhpName('Groupe'); $width = array(); // create a ModelJoin object for this join $j_groupes_classesJoin = new ModelJoin(); $j_groupes_classesJoin->setJoinType(Criteria::LEFT_JOIN); $j_groupes_classesRelation = $groupeTableMap->getRelation('JGroupesClasses'); $j_groupes_classesJoin->setRelationMap($j_groupes_classesRelation); $width["JGroupesClasses"] = new ModelWith($j_groupes_classesJoin); $classeJoin = new ModelJoin(); $classeJoin->setJoinType(Criteria::LEFT_JOIN); $jGroupesClassesTableMap = Propel::getDatabaseMap(GroupePeer::DATABASE_NAME)->getTableByPhpName('JGroupesClasses'); $relationClasse = $jGroupesClassesTableMap->getRelation('Classe'); $classeJoin->setRelationMap($relationClasse); $classeJoin->setPreviousJoin($j_groupes_classesJoin); $width["Classe"] = new ModelWith($classeJoin); $formatter->setWith($width); UtilisateurProfessionnel::$groupeFormatter = $formatter; } return UtilisateurProfessionnel::$groupeFormatter; }