本文整理汇总了PHP中Doctrine\ORM\Query\ResultSetMapping::addIndexByScalar方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSetMapping::addIndexByScalar方法的具体用法?PHP ResultSetMapping::addIndexByScalar怎么用?PHP ResultSetMapping::addIndexByScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query\ResultSetMapping
的用法示例。
在下文中一共展示了ResultSetMapping::addIndexByScalar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: walkFromClause
/**
* Walks down a FromClause AST node, thereby generating the appropriate SQL.
*
* @return string The SQL.
*/
public function walkFromClause($fromClause)
{
$identificationVarDecls = $fromClause->identificationVariableDeclarations;
$sqlParts = array();
foreach ($identificationVarDecls as $identificationVariableDecl) {
$sql = '';
$rangeDecl = $identificationVariableDecl->rangeVariableDeclaration;
$dqlAlias = $rangeDecl->aliasIdentificationVariable;
$this->_rootAliases[] = $dqlAlias;
$class = $this->_em->getClassMetadata($rangeDecl->abstractSchemaName);
$sql .= $class->getQuotedTableName($this->_platform) . ' ' . $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
if ($class->isInheritanceTypeJoined()) {
$sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias);
}
foreach ($identificationVariableDecl->joinVariableDeclarations as $joinVarDecl) {
$sql .= $this->walkJoinVariableDeclaration($joinVarDecl);
}
if ($identificationVariableDecl->indexBy) {
$alias = $identificationVariableDecl->indexBy->simpleStateFieldPathExpression->identificationVariable;
$field = $identificationVariableDecl->indexBy->simpleStateFieldPathExpression->field;
if (isset($this->_scalarFields[$alias][$field])) {
$this->_rsm->addIndexByScalar($this->_scalarFields[$alias][$field]);
} else {
$this->_rsm->addIndexBy($identificationVariableDecl->indexBy->simpleStateFieldPathExpression->identificationVariable, $identificationVariableDecl->indexBy->simpleStateFieldPathExpression->field);
}
}
$sqlParts[] = $this->_platform->appendLockHint($sql, $this->_query->getHint(Query::HINT_LOCK_MODE));
}
return ' FROM ' . implode(', ', $sqlParts);
}
示例2: walkFromClause
/**
* {@inheritdoc}
*/
public function walkFromClause($fromClause)
{
$identificationVarDecls = $fromClause->identificationVariableDeclarations;
$sqlParts = array();
foreach ($identificationVarDecls as $identificationVariableDecl) {
$sql = $this->platform->appendLockHint(
$this->walkRangeVariableDeclaration($identificationVariableDecl->rangeVariableDeclaration),
$this->query->getHint(Query::HINT_LOCK_MODE)
);
foreach ($identificationVariableDecl->joins as $join) {
$sql .= $this->walkJoin($join);
}
if ($identificationVariableDecl->indexBy) {
$alias = $identificationVariableDecl->indexBy->simpleStateFieldPathExpression->identificationVariable;
$field = $identificationVariableDecl->indexBy->simpleStateFieldPathExpression->field;
if (isset($this->scalarFields[$alias][$field])) {
$this->rsm->addIndexByScalar($this->scalarFields[$alias][$field]);
} else {
$this->rsm->addIndexBy(
$identificationVariableDecl->indexBy->simpleStateFieldPathExpression->identificationVariable,
$identificationVariableDecl->indexBy->simpleStateFieldPathExpression->field
);
}
}
$sqlParts[] = $sql;
}
return ' FROM ' . implode(', ', $sqlParts);
}
示例3: walkIndexBy
/**
* Walks down a IndexBy AST node.
*
* @param AST\IndexBy $indexBy
*
* @return void
*/
public function walkIndexBy($indexBy)
{
$pathExpression = $indexBy->simpleStateFieldPathExpression;
$alias = $pathExpression->identificationVariable;
$field = $pathExpression->field;
if (isset($this->scalarFields[$alias][$field])) {
$this->rsm->addIndexByScalar($this->scalarFields[$alias][$field]);
return;
}
$this->rsm->addIndexBy($alias, $field);
}
示例4: testIndexByScalarsOnly
/**
* SELECT UPPER(u.name) AS nameUpper
* FROM Doctrine\Tests\Models\CMS\CmsUser u
*
* @group DDC-1385
* @dataProvider provideDataForUserEntityResult
*/
public function testIndexByScalarsOnly($userEntityKey)
{
$rsm = new ResultSetMapping();
$rsm->addEntityResult('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addScalarResult('sclr0', 'nameUpper');
$rsm->addIndexByScalar('sclr0');
// Faked result set
$resultSet = array(array('sclr0' => 'ROMANB'), array('sclr0' => 'JWAGE'));
$stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true));
$this->assertEquals(array('ROMANB' => array('nameUpper' => 'ROMANB'), 'JWAGE' => array('nameUpper' => 'JWAGE')), $result);
}