本文整理汇总了PHP中QueryBuilder::innerJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::innerJoin方法的具体用法?PHP QueryBuilder::innerJoin怎么用?PHP QueryBuilder::innerJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::innerJoin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterByTranslation
/**
* Create filters according to any translation criteria OR argument.
*
* @param array $criteria
* @param QueryBuilder $qb
* @param Translation $translation
*/
protected function filterByTranslation(&$criteria, &$qb, &$translation = null)
{
if (isset($criteria['translation']) || isset($criteria['translation.locale']) || isset($criteria['translation.id'])) {
$qb->innerJoin('d.documentTranslations', 'dt');
$qb->innerJoin('dt.translation', 't');
} else {
if (null !== $translation) {
/*
* With a given translation
*/
$qb->innerJoin('d.documentTranslations', 'dt', 'WITH', 'dt.translation = :translation');
} else {
/*
* With a null translation, just take the default one.
*/
$qb->innerJoin('d.documentTranslations', 'dt');
$qb->innerJoin('dt.translation', 't', 'WITH', 't.defaultTranslation = true');
}
}
}
示例2: filterByCriteria
/**
* Reimplementing findBy features… with extra things.
*
* * key => array('<=', $value)
* * key => array('<', $value)
* * key => array('>=', $value)
* * key => array('>', $value)
* * key => array('BETWEEN', $value, $value)
* * key => array('LIKE', $value)
* * key => array('NOT IN', $array)
* * key => 'NOT NULL'
*
* You even can filter with node fields, examples:
*
* * `node.published => true`
* * `node.nodeName => 'page1'`
*
* @param array $criteria
* @param QueryBuilder $qb
* @param boolean $joinedNode
* @param boolean $joinedNodeType
*/
protected function filterByCriteria(&$criteria, &$qb, &$joinedNode = false, &$joinedNodeType = false)
{
/*
* Reimplementing findBy features…
*/
foreach ($criteria as $key => $value) {
if ($key == "tags" || $key == "tagExclusive") {
continue;
}
/*
* compute prefix for
* filtering node relation fields
*/
$prefix = 'ns.';
// Dots are forbidden in field definitions
$baseKey = str_replace('.', '_', $key);
if (false !== strpos($key, 'node.nodeType.')) {
if (!$joinedNode) {
$qb->innerJoin('ns.node', 'n');
$joinedNode = true;
}
if (!$joinedNodeType) {
$qb->innerJoin('n.nodeType', 'nt');
$joinedNodeType = true;
}
$prefix = 'nt.';
$key = str_replace('node.nodeType.', '', $key);
}
if (false !== strpos($key, 'node.')) {
if (!$joinedNode) {
$qb->innerJoin('ns.node', 'n');
$joinedNode = true;
}
$prefix = 'n.';
$key = str_replace('node.', '', $key);
}
$qb->andWhere($this->buildComparison($value, $prefix, $key, $baseKey, $qb));
}
}
示例3: filterByTranslation
/**
* Create filters according to any translation criteria OR argument.
*
* @param array $criteria
* @param QueryBuilder $qb
* @param Translation $translation
*/
protected function filterByTranslation(&$criteria, &$qb, &$translation = null)
{
if (isset($criteria['translation']) || isset($criteria['translation.locale']) || isset($criteria['translation.id']) || isset($criteria['translation.available'])) {
$qb->innerJoin('n.nodeSources', 'ns');
$qb->innerJoin('ns.translation', 't');
} else {
if (null !== $translation) {
/*
* With a given translation
*/
$qb->innerJoin('n.nodeSources', 'ns', 'WITH', 'ns.translation = :translation');
} else {
/*
* With a null translation, not filter by translation to enable
* nodes with only one translation which is not the default one.
*/
$qb->innerJoin('n.nodeSources', 'ns');
}
}
}