Coding style fixes.
This commit is contained in:
parent
a16ca32981
commit
44d7d23e8d
@ -33,7 +33,6 @@ use Doctrine\DBAL\LockMode,
|
|||||||
*/
|
*/
|
||||||
final class Query extends AbstractQuery
|
final class Query extends AbstractQuery
|
||||||
{
|
{
|
||||||
/* Query STATES */
|
|
||||||
/**
|
/**
|
||||||
* A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
|
* A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
|
||||||
*/
|
*/
|
||||||
@ -108,6 +107,7 @@ final class Query extends AbstractQuery
|
|||||||
*/
|
*/
|
||||||
const HINT_LOCK_MODE = 'doctrine.lockMode';
|
const HINT_LOCK_MODE = 'doctrine.lockMode';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer $_state The current state of this query.
|
* @var integer $_state The current state of this query.
|
||||||
*/
|
*/
|
||||||
@ -153,8 +153,6 @@ final class Query extends AbstractQuery
|
|||||||
*/
|
*/
|
||||||
private $_useQueryCache = true;
|
private $_useQueryCache = true;
|
||||||
|
|
||||||
// End of Caching Stuff
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new Query instance.
|
* Initializes a new Query instance.
|
||||||
*
|
*
|
||||||
@ -186,6 +184,7 @@ final class Query extends AbstractQuery
|
|||||||
public function getAST()
|
public function getAST()
|
||||||
{
|
{
|
||||||
$parser = new Parser($this);
|
$parser = new Parser($this);
|
||||||
|
|
||||||
return $parser->getAST();
|
return $parser->getAST();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,9 +198,7 @@ final class Query extends AbstractQuery
|
|||||||
private function _parse()
|
private function _parse()
|
||||||
{
|
{
|
||||||
// Return previous parser result if the query and the filter collection are both clean
|
// Return previous parser result if the query and the filter collection are both clean
|
||||||
if ($this->_state === self::STATE_CLEAN
|
if ($this->_state === self::STATE_CLEAN && $this->_em->isFiltersStateClean()) {
|
||||||
&& $this->_em->isFiltersStateClean()
|
|
||||||
) {
|
|
||||||
return $this->_parserResult;
|
return $this->_parserResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +207,7 @@ final class Query extends AbstractQuery
|
|||||||
// Check query cache.
|
// Check query cache.
|
||||||
if ( ! ($this->_useQueryCache && ($queryCache = $this->getQueryCacheDriver()))) {
|
if ( ! ($this->_useQueryCache && ($queryCache = $this->getQueryCacheDriver()))) {
|
||||||
$parser = new Parser($this);
|
$parser = new Parser($this);
|
||||||
|
|
||||||
$this->_parserResult = $parser->parse();
|
$this->_parserResult = $parser->parse();
|
||||||
|
|
||||||
return $this->_parserResult;
|
return $this->_parserResult;
|
||||||
@ -227,7 +225,9 @@ final class Query extends AbstractQuery
|
|||||||
|
|
||||||
// Cache miss.
|
// Cache miss.
|
||||||
$parser = new Parser($this);
|
$parser = new Parser($this);
|
||||||
|
|
||||||
$this->_parserResult = $parser->parse();
|
$this->_parserResult = $parser->parse();
|
||||||
|
|
||||||
$queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL);
|
$queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL);
|
||||||
|
|
||||||
return $this->_parserResult;
|
return $this->_parserResult;
|
||||||
@ -282,7 +282,9 @@ final class Query extends AbstractQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sqlPositions = $paramMappings[$key];
|
$sqlPositions = $paramMappings[$key];
|
||||||
// optimized multi value sql positions away for now, they are not allowed in DQL anyways.
|
|
||||||
|
// optimized multi value sql positions away for now,
|
||||||
|
// they are not allowed in DQL anyways.
|
||||||
$value = array($value);
|
$value = array($value);
|
||||||
$countValue = count($value);
|
$countValue = count($value);
|
||||||
|
|
||||||
@ -554,7 +556,7 @@ final class Query extends AbstractQuery
|
|||||||
*/
|
*/
|
||||||
public function setLockMode($lockMode)
|
public function setLockMode($lockMode)
|
||||||
{
|
{
|
||||||
if ($lockMode === LockMode::PESSIMISTIC_READ || $lockMode === LockMode::PESSIMISTIC_WRITE) {
|
if (in_array($lockMode, array(LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE))) {
|
||||||
if ( ! $this->_em->getConnection()->isTransactionActive()) {
|
if ( ! $this->_em->getConnection()->isTransactionActive()) {
|
||||||
throw TransactionRequiredException::transactionRequired();
|
throw TransactionRequiredException::transactionRequired();
|
||||||
}
|
}
|
||||||
|
@ -326,11 +326,7 @@ class QueryBuilder
|
|||||||
{
|
{
|
||||||
$key = trim($key, ':');
|
$key = trim($key, ':');
|
||||||
|
|
||||||
if ($type === null) {
|
$this->_paramTypes[$key] = $type ?: Query\ParameterTypeInferer::inferType($value);
|
||||||
$type = Query\ParameterTypeInferer::inferType($value);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_paramTypes[$key] = $type;
|
|
||||||
$this->_params[$key] = $value;
|
$this->_params[$key] = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -450,13 +446,13 @@ class QueryBuilder
|
|||||||
// TODO: Remove for 3.0
|
// TODO: Remove for 3.0
|
||||||
if ($dqlPartName == 'join') {
|
if ($dqlPartName == 'join') {
|
||||||
$newDqlPart = array();
|
$newDqlPart = array();
|
||||||
|
|
||||||
foreach ($dqlPart AS $k => $v) {
|
foreach ($dqlPart AS $k => $v) {
|
||||||
if (is_numeric($k)) {
|
$k = is_numeric($k) ? $this->getRootAlias() : $k;
|
||||||
$newDqlPart[$this->getRootAlias()] = $v;
|
|
||||||
} else {
|
|
||||||
$newDqlPart[$k] = $v;
|
$newDqlPart[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$dqlPart = $newDqlPart;
|
$dqlPart = $newDqlPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +516,7 @@ class QueryBuilder
|
|||||||
public function distinct($flag = true)
|
public function distinct($flag = true)
|
||||||
{
|
{
|
||||||
$this->_dqlParts['distinct'] = (bool) $flag;
|
$this->_dqlParts['distinct'] = (bool) $flag;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,8 +940,9 @@ class QueryBuilder
|
|||||||
*/
|
*/
|
||||||
public function orderBy($sort, $order = null)
|
public function orderBy($sort, $order = null)
|
||||||
{
|
{
|
||||||
return $this->add('orderBy', $sort instanceof Expr\OrderBy ? $sort
|
$orderBy = ($sort instanceof Expr\OrderBy) ? $sort : new Expr\OrderBy($sort, $order);
|
||||||
: new Expr\OrderBy($sort, $order));
|
|
||||||
|
return $this->add('orderBy', $orderBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1059,9 +1057,11 @@ class QueryBuilder
|
|||||||
if (is_null($parts)) {
|
if (is_null($parts)) {
|
||||||
$parts = array_keys($this->_dqlParts);
|
$parts = array_keys($this->_dqlParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$this->resetDQLPart($part);
|
$this->resetDQLPart($part);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,12 +1073,9 @@ class QueryBuilder
|
|||||||
*/
|
*/
|
||||||
public function resetDQLPart($part)
|
public function resetDQLPart($part)
|
||||||
{
|
{
|
||||||
if (is_array($this->_dqlParts[$part])) {
|
$this->_dqlParts[$part] = is_array($this->_dqlParts[$part]) ? array() : null;
|
||||||
$this->_dqlParts[$part] = array();
|
|
||||||
} else {
|
|
||||||
$this->_dqlParts[$part] = null;
|
|
||||||
}
|
|
||||||
$this->_state = self::STATE_DIRTY;
|
$this->_state = self::STATE_DIRTY;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,7 +1104,7 @@ class QueryBuilder
|
|||||||
$this->_dqlParts[$part][$idx] = clone $element;
|
$this->_dqlParts[$part][$idx] = clone $element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (\is_object($elements)) {
|
} else if (is_object($elements)) {
|
||||||
$this->_dqlParts[$part] = clone $elements;
|
$this->_dqlParts[$part] = clone $elements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user