本文整理汇总了PHP中QueryBuilder::leftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::leftJoin方法的具体用法?PHP QueryBuilder::leftJoin怎么用?PHP QueryBuilder::leftJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::leftJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param Librarian $librarian The librarian interface responsible for the query
* @param DBAL\Connection $db A Doctrine Connection
* @param int $limit The maximum number of results to return
* @param array $orderBy An assoc. array of indexName => direction
* @param array $indexes An assoc. array of indexName => Index
*/
public function __construct(LibrarianInterface $librarian, DBAL\Connection $db, $limit, array $orderBy, array $indexes)
{
$this->librarian = $librarian;
$this->indexes = $indexes;
$this->db = $db;
$this->limit = $limit;
$this->queryBuilder = $this->db->createQueryBuilder();
$this->queryBuilder->setMaxResults($limit);
foreach ($this->indexes as $index) {
$index->setQuery($this);
$index->setQueryBuilder($this->queryBuilder);
}
// TODO: make this explicitly defined?
$this->mainIndex = current($this->indexes);
foreach (array_slice($this->indexes, 1) as $name => $index) {
$this->queryBuilder->leftJoin($this->mainIndex->getName(), $index->getTableName(), $index->getName($quote = true), $this->mainIndex->getName() . '.id = ' . $this->db->quoteIdentifier($name) . '.id');
}
$this->queryBuilder->select('distinct ' . $this->mainIndex->getName() . '.id')->from($this->mainIndex->getTableName(), $this->mainIndex->getName($quote = true));
foreach ($orderBy as $name => $direction) {
$this->indexes[$name]->orderBy($direction);
}
}
示例2: addJoinsToFrom
/**
* Helper method to add joins to from clause.
*
* @param Doctrine\ORM\QueryBuilder $qb query builder instance used to create the query.
*
* @return String Enhancement for from clause.
*/
protected function addJoinsToFrom(QueryBuilder $qb)
{
$qb->leftJoin('tbl.category', 'tblCategory');
// $qb->leftJoin('tbl.posting', 'tblPosting');
return $qb;
}