本文整理匯總了PHP中Doctrine\ORM\QueryBuilder::getDql方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryBuilder::getDql方法的具體用法?PHP QueryBuilder::getDql怎麽用?PHP QueryBuilder::getDql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getDql方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assertValidQueryBuilder
protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql)
{
$dql = $qb->getDql();
$q = $qb->getQuery();
$this->assertEquals($expectedDql, $dql);
}
示例2: addOrder
/**
* Build and add an oder field to the query builder.
*
* @param \Doctrine\Orm\QueryBuilder $qb
* @param mixed $order
* @return Gmg_Service_Abstract
*/
protected function addOrder($qb, $order)
{
// add the where expression to the query
// process the $order
if (is_string($order)) {
// straight DQL string
$qb->orderBy($order);
} elseif (is_array($order) && count($order)) {
// loop through each order clause supplied
foreach ($order as $col => $dir) {
// set the alias to the default
$alias = $this->alias;
// if col relates to Relation i.e. Role.id
// then set up the alias and column names (the join should have
// already been performed in the $where)
// TODO: this will cause an error if the column wasn't specified in the $where
if (strpos($col, '.') !== false) {
$parts = explode('.', $col);
$col = array_pop($parts);
$par = $this->alias;
// test for existing joins
$as = array();
foreach ($qb->getDQLPart('join') as $j) {
$as[] = $j;
}
foreach ($parts as $rel) {
$alias = strtolower($rel);
$jt = new Expr\Join(Expr\Join::LEFT_JOIN, $par . '.' . $rel, $alias);
if (!strpos($qb->getDql(), $jt->__toString()) !== false) {
$qb->leftJoin($par . '.' . $rel, $alias);
}
$par = $alias;
}
}
$qb->addOrderBy($alias . '.' . $col, $dir);
}
}
return $this;
}