Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
33fc28ff
Commit
33fc28ff
authored
Aug 06, 2009
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Updated AST nodes to use public properties instead of setter/getter methods.
parent
f087a005
Changes
64
Show whitespace changes
Inline
Side-by-side
Showing
64 changed files
with
1835 additions
and
1821 deletions
+1835
-1821
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+8
-3
AbstractQuery.php
lib/Doctrine/ORM/AbstractQuery.php
+2
-0
ArithmeticFactor.php
lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php
+39
-18
ArithmeticTerm.php
lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php
+27
-11
BetweenExpression.php
lib/Doctrine/ORM/Query/AST/BetweenExpression.php
+33
-37
CollectionMemberExpression.php
lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php
+29
-5
ComparisonExpression.php
lib/Doctrine/ORM/Query/AST/ComparisonExpression.php
+13
-22
ComparisonOperator.php
lib/Doctrine/ORM/Query/AST/ComparisonOperator.php
+0
-42
ConditionalExpression.php
lib/Doctrine/ORM/Query/AST/ConditionalExpression.php
+27
-11
ConditionalFactor.php
lib/Doctrine/ORM/Query/AST/ConditionalFactor.php
+29
-19
ConditionalPrimary.php
lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php
+29
-28
ConditionalTerm.php
lib/Doctrine/ORM/Query/AST/ConditionalTerm.php
+27
-11
DeleteClause.php
lib/Doctrine/ORM/Query/AST/DeleteClause.php
+11
-18
DeleteStatement.php
lib/Doctrine/ORM/Query/AST/DeleteStatement.php
+10
-23
EmptyCollectionComparisonExpression.php
...ine/ORM/Query/AST/EmptyCollectionComparisonExpression.php
+30
-20
ExistsExpression.php
lib/Doctrine/ORM/Query/AST/ExistsExpression.php
+28
-22
FromClause.php
lib/Doctrine/ORM/Query/AST/FromClause.php
+10
-14
AbsFunction.php
lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php
+30
-13
ConcatFunction.php
lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php
+31
-20
CurrentDateFunction.php
lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php
+27
-2
CurrentTimeFunction.php
lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php
+25
-4
FunctionNode.php
lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php
+10
-9
LengthFunction.php
lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php
+31
-12
LocateFunction.php
lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
+44
-34
LowerFunction.php
lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php
+31
-12
ModFunction.php
lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php
+39
-23
SizeFunction.php
lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
+14
-15
SqrtFunction.php
lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php
+31
-12
SubstringFunction.php
lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php
+42
-33
TrimFunction.php
lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php
+51
-67
UpperFunction.php
lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php
+31
-12
GroupByClause.php
lib/Doctrine/ORM/Query/AST/GroupByClause.php
+27
-11
HavingClause.php
lib/Doctrine/ORM/Query/AST/HavingClause.php
+27
-11
IdentificationVariableDeclaration.php
...trine/ORM/Query/AST/IdentificationVariableDeclaration.php
+13
-31
InExpression.php
lib/Doctrine/ORM/Query/AST/InExpression.php
+30
-44
IndexBy.php
lib/Doctrine/ORM/Query/AST/IndexBy.php
+9
-13
InputParameter.php
lib/Doctrine/ORM/Query/AST/InputParameter.php
+29
-33
Join.php
lib/Doctrine/ORM/Query/AST/Join.php
+15
-51
JoinAssociationPathExpression.php
lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php
+32
-18
JoinVariableDeclaration.php
lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php
+11
-20
LikeExpression.php
lib/Doctrine/ORM/Query/AST/LikeExpression.php
+33
-33
Node.php
lib/Doctrine/ORM/Query/AST/Node.php
+7
-7
NullComparisonExpression.php
lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php
+29
-23
OrderByClause.php
lib/Doctrine/ORM/Query/AST/OrderByClause.php
+27
-11
OrderByItem.php
lib/Doctrine/ORM/Query/AST/OrderByItem.php
+14
-28
PathExpression.php
lib/Doctrine/ORM/Query/AST/PathExpression.php
+35
-53
QuantifiedExpression.php
lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php
+31
-27
RangeVariableDeclaration.php
lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php
+13
-27
SelectClause.php
lib/Doctrine/ORM/Query/AST/SelectClause.php
+11
-38
SelectExpression.php
lib/Doctrine/ORM/Query/AST/SelectExpression.php
+11
-20
SelectStatement.php
lib/Doctrine/ORM/Query/AST/SelectStatement.php
+17
-51
SimpleArithmeticExpression.php
lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php
+27
-11
SimpleSelectClause.php
lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php
+12
-25
SimpleSelectExpression.php
lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php
+11
-24
Subselect.php
lib/Doctrine/ORM/Query/AST/Subselect.php
+15
-64
SubselectFromClause.php
lib/Doctrine/ORM/Query/AST/SubselectFromClause.php
+9
-13
UpdateClause.php
lib/Doctrine/ORM/Query/AST/UpdateClause.php
+31
-28
UpdateItem.php
lib/Doctrine/ORM/Query/AST/UpdateItem.php
+12
-27
UpdateStatement.php
lib/Doctrine/ORM/Query/AST/UpdateStatement.php
+10
-23
WhereClause.php
lib/Doctrine/ORM/Query/AST/WhereClause.php
+28
-12
MultiTableDeleteExecutor.php
lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
+4
-4
MultiTableUpdateExecutor.php
lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php
+14
-11
Parser.php
lib/Doctrine/ORM/Query/Parser.php
+119
-125
SqlWalker.php
lib/Doctrine/ORM/Query/SqlWalker.php
+333
-332
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
33fc28ff
...
@@ -30,7 +30,12 @@ use Doctrine\DBAL\Types;
...
@@ -30,7 +30,12 @@ use Doctrine\DBAL\Types;
* point of abstraction of platform-specific behaviors, features and SQL dialects.
* point of abstraction of platform-specific behaviors, features and SQL dialects.
* They are a passive source of information.
* They are a passive source of information.
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
*/
...
...
lib/Doctrine/ORM/AbstractQuery.php
View file @
33fc28ff
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
namespace
Doctrine\ORM
;
namespace
Doctrine\ORM
;
use
Doctrine\ORM\Query\QueryException
;
/**
/**
* Base class for Query and NativeQuery.
* Base class for Query and NativeQuery.
*
*
...
...
lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,34 +24,40 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,34 +24,40 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary
* ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ArithmeticFactor
extends
Node
class
ArithmeticFactor
extends
Node
{
{
private
$_arithmeticPrimary
;
/**
private
$_pSigned
;
* @var ArithmeticPrimary
private
$_nSigned
;
*/
public
$arithmeticPrimary
;
public
function
__construct
(
$arithmeticPrimary
,
$pSigned
=
false
,
$nSigned
=
false
)
/**
{
* @var null|boolean NULL represents no sign, TRUE means positive and FALSE means negative sign
$this
->
_arithmeticPrimary
=
$arithmeticPrimary
;
*/
$this
->
_pSigned
=
$pSigned
;
public
$sign
;
$this
->
_nSigned
=
$nSigned
;
}
public
function
getArithmeticPrimary
(
)
public
function
__construct
(
$arithmeticPrimary
,
$sign
=
null
)
{
{
return
$this
->
_arithmeticPrimary
;
$this
->
arithmeticPrimary
=
$arithmeticPrimary
;
$this
->
sign
=
$sign
;
}
}
public
function
isPositiveSigned
()
public
function
isPositiveSigned
()
{
{
return
$this
->
_pSigned
;
return
$this
->
sign
===
true
;
}
}
public
function
isNegativeSigned
()
public
function
isNegativeSigned
()
{
{
return
$this
->
_nSigned
;
return
$this
->
sign
===
false
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}*
* ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}*
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ArithmeticTerm
extends
Node
class
ArithmeticTerm
extends
Node
{
{
p
rivate
$_f
actors
;
p
ublic
$arithmeticF
actors
;
public
function
__construct
(
array
$arithmeticFactors
)
public
function
__construct
(
array
$arithmeticFactors
)
{
{
$this
->
_factors
=
$arithmeticFactors
;
$this
->
arithmeticFactors
=
$arithmeticFactors
;
}
public
function
getArithmeticFactors
()
{
return
$this
->
_factors
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/BetweenExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,45 +24,26 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,45 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Description of BetweenExpression
* Description of BetweenExpression
*
*
* @author robo
@license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
BetweenExpression
extends
Node
class
BetweenExpression
extends
Node
{
{
private
$_baseExpression
;
public
$expression
;
private
$_leftBetweenExpression
;
public
$leftBetweenExpression
;
private
$_rightBetweenExpression
;
public
$rightBetweenExpression
;
private
$_not
;
public
$not
;
public
function
__construct
(
$baseExpr
,
$leftExpr
,
$rightExpr
)
{
$this
->
_baseExpression
=
$baseExpr
;
$this
->
_leftBetweenExpression
=
$leftExpr
;
$this
->
_rightBetweenExpression
=
$rightExpr
;
}
public
function
getBaseExpression
()
{
return
$this
->
_baseExpression
;
}
public
function
getLeftBetweenExpression
()
{
return
$this
->
_leftBetweenExpression
;
}
public
function
getRightBetweenExpression
()
{
return
$this
->
_rightBetweenExpression
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
getNot
(
)
public
function
__construct
(
$expr
,
$leftExpr
,
$rightExpr
)
{
{
return
$this
->
_not
;
$this
->
expression
=
$expr
;
$this
->
leftBetweenExpression
=
$leftExpr
;
$this
->
rightBetweenExpression
=
$rightExpr
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php
View file @
33fc28ff
<?php
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression
* CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
CollectionMemberExpression
extends
Node
class
CollectionMemberExpression
extends
Node
{
{
public
$entityExpression
;
public
$entityExpression
;
public
$collectionValuedPathExpression
;
public
$collectionValuedPathExpression
;
public
$
isN
ot
;
public
$
n
ot
;
public
function
__construct
(
$entityExpr
,
$collValuedPathExpr
,
$isNot
)
public
function
__construct
(
$entityExpr
,
$collValuedPathExpr
)
{
{
$this
->
entityExpression
=
$entityExpr
;
$this
->
entityExpression
=
$entityExpr
;
$this
->
collectionValuedPathExpression
=
$collValuedPathExpr
;
$this
->
collectionValuedPathExpression
=
$collValuedPathExpr
;
$this
->
isNot
=
$isNot
;
}
}
public
function
dispatch
(
$walker
)
public
function
dispatch
(
$walker
)
...
...
lib/Doctrine/ORM/Query/AST/ComparisonExpression.php
View file @
33fc28ff
...
@@ -29,34 +29,25 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -29,34 +29,25 @@ namespace Doctrine\ORM\Query\AST;
* DatetimeExpression ComparisonOperator (DatetimeExpression | QuantifiedExpression) |
* DatetimeExpression ComparisonOperator (DatetimeExpression | QuantifiedExpression) |
* EntityExpression ("=" | "<>") (EntityExpression | QuantifiedExpression)
* EntityExpression ("=" | "<>") (EntityExpression | QuantifiedExpression)
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ComparisonExpression
extends
Node
class
ComparisonExpression
extends
Node
{
{
p
rivate
$_leftExpr
;
p
ublic
$leftExpression
;
p
rivate
$_rightExpr
;
p
ublic
$rightExpression
;
p
rivate
$_
operator
;
p
ublic
$
operator
;
public
function
__construct
(
$leftExpr
,
$operator
,
$rightExpr
)
public
function
__construct
(
$leftExpr
,
$operator
,
$rightExpr
)
{
{
$this
->
_leftExpr
=
$leftExpr
;
$this
->
leftExpression
=
$leftExpr
;
$this
->
_rightExpr
=
$rightExpr
;
$this
->
rightExpression
=
$rightExpr
;
$this
->
_operator
=
$operator
;
$this
->
operator
=
$operator
;
}
public
function
getLeftExpression
()
{
return
$this
->
_leftExpr
;
}
public
function
getRightExpression
()
{
return
$this
->
_rightExpr
;
}
public
function
getOperator
()
{
return
$this
->
_operator
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ComparisonOperator.php
deleted
100644 → 0
View file @
f087a005
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
/**
* ComparisonOperator = "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
*
* @package Doctrine
* @subpackage Query
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class
ComparisonOperator
extends
Node
{
public
function
dispatch
(
$sqlWalker
)
{
;
}
}
\ No newline at end of file
lib/Doctrine/ORM/Query/AST/ConditionalExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
* ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ConditionalExpression
extends
Node
class
ConditionalExpression
extends
Node
{
{
p
rivate
$_
conditionalTerms
=
array
();
p
ublic
$
conditionalTerms
=
array
();
public
function
__construct
(
array
$conditionalTerms
)
public
function
__construct
(
array
$conditionalTerms
)
{
{
$this
->
_conditionalTerms
=
$conditionalTerms
;
$this
->
conditionalTerms
=
$conditionalTerms
;
}
public
function
getConditionalTerms
()
{
return
$this
->
_conditionalTerms
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalFactor.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,27 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,27 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ConditionalFactor ::= ["NOT"] ConditionalPrimary
* ConditionalFactor ::= ["NOT"] ConditionalPrimary
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ConditionalFactor
extends
Node
class
ConditionalFactor
extends
Node
{
{
private
$_not
=
false
;
public
$not
=
false
;
private
$_conditionalPrimary
;
public
$conditionalPrimary
;
public
function
__construct
(
$conditionalPrimary
,
$not
=
false
)
{
$this
->
_conditionalPrimary
=
$conditionalPrimary
;
$this
->
_not
=
$not
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
public
function
getConditionalPrimary
(
)
public
function
__construct
(
$conditionalPrimary
)
{
{
return
$this
->
_
conditionalPrimary
;
$this
->
conditionalPrimary
=
$
conditionalPrimary
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,41 +24,27 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,41 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
* ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ConditionalPrimary
extends
Node
class
ConditionalPrimary
extends
Node
{
{
private
$_simpleConditionalExpression
;
public
$simpleConditionalExpression
;
private
$_conditionalExpression
;
public
$conditionalExpression
;
public
function
setSimpleConditionalExpression
(
$simpleConditionalExpr
)
{
$this
->
_simpleConditionalExpression
=
$simpleConditionalExpr
;
}
public
function
setConditionalExpression
(
$conditionalExpr
)
{
$this
->
_conditionalExpression
=
$conditionalExpr
;
}
public
function
getSimpleConditionalExpression
()
{
return
$this
->
_simpleConditionalExpression
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
}
public
function
isSimpleConditionalExpression
()
public
function
isSimpleConditionalExpression
()
{
{
return
(
bool
)
$this
->
_
simpleConditionalExpression
;
return
(
bool
)
$this
->
simpleConditionalExpression
;
}
}
public
function
isConditionalExpression
()
public
function
isConditionalExpression
()
{
{
return
(
bool
)
$this
->
_
conditionalExpression
;
return
(
bool
)
$this
->
conditionalExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalTerm.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
* ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ConditionalTerm
extends
Node
class
ConditionalTerm
extends
Node
{
{
p
rivate
$_
conditionalFactors
=
array
();
p
ublic
$
conditionalFactors
=
array
();
public
function
__construct
(
array
$conditionalFactors
)
public
function
__construct
(
array
$conditionalFactors
)
{
{
$this
->
_conditionalFactors
=
$conditionalFactors
;
$this
->
conditionalFactors
=
$conditionalFactors
;
}
public
function
getConditionalFactors
()
{
return
$this
->
_conditionalFactors
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/DeleteClause.php
View file @
33fc28ff
...
@@ -23,30 +23,23 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -23,30 +23,23 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName [["AS"] AliasIdentificationVariable]
* DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName [["AS"] AliasIdentificationVariable]
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
DeleteClause
extends
Node
class
DeleteClause
extends
Node
{
{
p
rivate
$_
abstractSchemaName
;
p
ublic
$
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
ublic
$
aliasIdentificationVariable
;
public
function
__construct
(
$abstractSchemaName
)
public
function
__construct
(
$abstractSchemaName
)
{
{
$this
->
_abstractSchemaName
=
$abstractSchemaName
;
$this
->
abstractSchemaName
=
$abstractSchemaName
;
}
public
function
getAbstractSchemaName
()
{
return
$this
->
_abstractSchemaName
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
setAliasIdentificationVariable
(
$alias
)
{
$this
->
_aliasIdentificationVariable
=
$alias
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/DeleteStatement.php
View file @
33fc28ff
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* DeleteStatement = DeleteClause [WhereClause]
* DeleteStatement = DeleteClause [WhereClause]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
DeleteStatement
extends
Node
class
DeleteStatement
extends
Node
{
{
p
rivate
$_
deleteClause
;
p
ublic
$
deleteClause
;
p
rivate
$_
whereClause
;
p
ublic
$
whereClause
;
public
function
__construct
(
$deleteClause
)
public
function
__construct
(
$deleteClause
)
{
{
$this
->
_deleteClause
=
$deleteClause
;
$this
->
deleteClause
=
$deleteClause
;
}
public
function
setWhereClause
(
$whereClause
)
{
$this
->
_whereClause
=
$whereClause
;
}
public
function
getDeleteClause
()
{
return
$this
->
_deleteClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php
View file @
33fc28ff
<?php
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"
* EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
EmptyCollectionComparisonExpression
extends
Node
class
EmptyCollectionComparisonExpression
extends
Node
{
{
p
rivate
$_
expression
;
p
ublic
$
expression
;
p
rivate
$_
not
;
p
ublic
$
not
;
public
function
__construct
(
$expression
)
public
function
__construct
(
$expression
)
{
{
$this
->
_expression
=
$expression
;
$this
->
expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ExistsExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"
* ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ExistsExpression
extends
Node
class
ExistsExpression
extends
Node
{
{
p
rivate
$_not
=
false
;
p
ublic
$not
;
p
rivate
$_
subselect
;
p
ublic
$
subselect
;
public
function
__construct
(
$subselect
)
public
function
__construct
(
$subselect
)
{
{
$this
->
_subselect
=
$subselect
;
$this
->
subselect
=
$subselect
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
public
function
getSubselect
()
{
return
$this
->
_subselect
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/FromClause.php
View file @
33fc28ff
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
*
*
* This software consists of voluntary contributions made by many individuals
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
* FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
FromClause
extends
Node
class
FromClause
extends
Node
{
{
p
rotected
$_
identificationVariableDeclarations
=
array
();
p
ublic
$
identificationVariableDeclarations
=
array
();
public
function
__construct
(
array
$identificationVariableDeclarations
)
public
function
__construct
(
array
$identificationVariableDeclarations
)
{
{
$this
->
_identificationVariableDeclarations
=
$identificationVariableDeclarations
;
$this
->
identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
/* Getters */
public
function
getIdentificationVariableDeclarations
()
{
return
$this
->
_identificationVariableDeclarations
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,24 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,24 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "ABS" "(" SimpleArithmeticExpression ")"
* "ABS" "(" SimpleArithmeticExpression ")"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
AbsFunction
extends
FunctionNode
class
AbsFunction
extends
FunctionNode
{
{
private
$_simpleArithmeticExpression
;
public
$simpleArithmeticExpression
;
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
/**
/**
* @override
* @override
*/
*/
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
return
'ABS('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
return
'ABS('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_simpleArithmeticExpression
)
.
')'
;
$this
->
simpleArithmeticExpression
)
.
')'
;
}
}
/**
/**
...
@@ -37,7 +54,7 @@ class AbsFunction extends FunctionNode
...
@@ -37,7 +54,7 @@ class AbsFunction extends FunctionNode
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "CONCAT" "(" StringPrimary "," StringPrimary ")"
* "CONCAT" "(" StringPrimary "," StringPrimary ")"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ConcatFunction
extends
FunctionNode
class
ConcatFunction
extends
FunctionNode
{
{
private
$_firstStringPrimary
;
public
$firstStringPrimary
;
private
$_secondStringPriamry
;
public
$secondStringPriamry
;
public
function
getFirstStringPrimary
()
{
return
$this
->
_firstStringPrimary
;
}
public
function
getSecondStringPrimary
()
{
return
$this
->
_secondStringPrimary
;
}
/**
/**
* @override
* @override
...
@@ -33,8 +44,8 @@ class ConcatFunction extends FunctionNode
...
@@ -33,8 +44,8 @@ class ConcatFunction extends FunctionNode
{
{
$platform
=
$sqlWalker
->
getConnection
()
->
getDatabasePlatform
();
$platform
=
$sqlWalker
->
getConnection
()
->
getDatabasePlatform
();
return
$platform
->
getConcatExpression
(
return
$platform
->
getConcatExpression
(
$sqlWalker
->
walkStringPrimary
(
$this
->
_
firstStringPrimary
),
$sqlWalker
->
walkStringPrimary
(
$this
->
firstStringPrimary
),
$sqlWalker
->
walkStringPrimary
(
$this
->
_
secondStringPrimary
)
$sqlWalker
->
walkStringPrimary
(
$this
->
secondStringPrimary
)
);
);
}
}
...
@@ -47,9 +58,9 @@ class ConcatFunction extends FunctionNode
...
@@ -47,9 +58,9 @@ class ConcatFunction extends FunctionNode
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_
firstStringPrimary
=
$parser
->
StringPrimary
();
$this
->
firstStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_
secondStringPrimary
=
$parser
->
StringPrimary
();
$this
->
secondStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php
View file @
33fc28ff
<?php
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
/**
/**
* "CURRENT_DATE"
* "CURRENT_DATE"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
CurrentDateFunction
extends
FunctionNode
class
CurrentDateFunction
extends
FunctionNode
{
{
...
...
lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,7 +24,13 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,7 +24,13 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "CURRENT_TIME"
* "CURRENT_TIME"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
CurrentTimeFunction
extends
FunctionNode
class
CurrentTimeFunction
extends
FunctionNode
{
{
...
...
lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php
View file @
33fc28ff
...
@@ -24,22 +24,23 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -24,22 +24,23 @@ namespace Doctrine\ORM\Query\AST\Functions;
use
Doctrine\ORM\Query\AST\Node
;
use
Doctrine\ORM\Query\AST\Node
;
/**
/**
*
Description of Function
*
Abtract Function Node.
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
abstract
class
FunctionNode
extends
Node
abstract
class
FunctionNode
extends
Node
{
{
p
rivate
$_
name
;
p
ublic
$
name
;
public
function
__construct
(
$name
)
public
function
__construct
(
$name
)
{
{
$this
->
_name
=
$name
;
$this
->
name
=
$name
;
}
public
function
getName
()
{
return
$this
->
_name
;
}
}
abstract
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
);
abstract
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
);
...
...
lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "LENGTH" "(" StringPrimary ")"
* "LENGTH" "(" StringPrimary ")"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
LengthFunction
extends
FunctionNode
class
LengthFunction
extends
FunctionNode
{
{
private
$_stringPrimary
;
public
$stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
/**
/**
* @override
* @override
...
@@ -26,7 +42,7 @@ class LengthFunction extends FunctionNode
...
@@ -26,7 +42,7 @@ class LengthFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
return
'LENGTH('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_
stringPrimary
)
.
')'
;
return
'LENGTH('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
')'
;
}
}
/**
/**
...
@@ -35,9 +51,12 @@ class LengthFunction extends FunctionNode
...
@@ -35,9 +51,12 @@ class LengthFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")"
* "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
LocateFunction
extends
FunctionNode
class
LocateFunction
extends
FunctionNode
{
{
private
$_firstStringPrimary
;
public
$firstStringPrimary
;
private
$_secondStringPrimary
;
public
$secondStringPrimary
;
private
$_simpleArithmeticExpression
;
public
$simpleArithmeticExpression
;
public
function
getFirstStringPrimary
()
{
return
$this
->
_firstStringPrimary
;
}
public
function
getSecondStringPrimary
()
{
return
$this
->
_secondStringPrimary
;
}
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
/**
/**
* @override
* @override
...
@@ -38,15 +44,12 @@ class LocateFunction extends FunctionNode
...
@@ -38,15 +44,12 @@ class LocateFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
$sql
=
'LOCATE('
.
return
'LOCATE('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
firstStringPrimary
)
.
', '
$sqlWalker
->
walkStringPrimary
(
$this
->
_firstStringPrimary
)
.
$sqlWalker
->
walkStringPrimary
(
$this
->
secondStringPrimary
)
.
', '
.
.
((
$this
->
simpleArithmeticExpression
)
$sqlWalker
->
walkStringPrimary
(
$this
->
_secondStringPrimary
);
?
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
simpleArithmeticExpression
)
:
''
if
(
$this
->
_simpleArithmeticExpression
)
{
)
.
')'
;
$sql
.=
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_simpleArithmeticExpression
);
}
return
$sql
.
')'
;
}
}
/**
/**
...
@@ -55,15 +58,22 @@ class LocateFunction extends FunctionNode
...
@@ -55,15 +58,22 @@ class LocateFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_firstStringPrimary
=
$parser
->
StringPrimary
();
$this
->
firstStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_secondStringPrimary
=
$parser
->
StringPrimary
();
$this
->
secondStringPrimary
=
$parser
->
StringPrimary
();
if
(
$lexer
->
isNextToken
(
','
))
{
if
(
$lexer
->
isNextToken
(
','
))
{
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
}
}
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "LOWER" "(" StringPrimary ")"
* "LOWER" "(" StringPrimary ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
LowerFunction
extends
FunctionNode
class
LowerFunction
extends
FunctionNode
{
{
private
$_stringPrimary
;
public
$stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
/**
/**
* @override
* @override
...
@@ -26,7 +42,7 @@ class LowerFunction extends FunctionNode
...
@@ -26,7 +42,7 @@ class LowerFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
return
'LOWER('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_
stringPrimary
)
.
')'
;
return
'LOWER('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
')'
;
}
}
/**
/**
...
@@ -35,9 +51,12 @@ class LowerFunction extends FunctionNode
...
@@ -35,9 +51,12 @@ class LowerFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
* "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
ModFunction
extends
FunctionNode
class
ModFunction
extends
FunctionNode
{
{
private
$_firstSimpleArithmeticExpression
;
public
$firstSimpleArithmeticExpression
;
private
$_secondSimpleArithmeticExpression
;
public
$secondSimpleArithmeticExpression
;
public
function
getFirstSimpleArithmeticExpression
()
{
return
$this
->
_firstSimpleArithmeticExpression
;
}
public
function
getSecondSimpleArithmeticExpression
()
{
return
$this
->
_secondSimpleArithmeticExpression
;
}
/**
/**
* @override
* @override
...
@@ -32,10 +43,10 @@ class ModFunction extends FunctionNode
...
@@ -32,10 +43,10 @@ class ModFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
return
'SQRT('
.
return
'SQRT('
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_firstSimpleArithmeticExpression
)
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_firstSimpleArithmeticExpression
)
.
', '
.
.
', '
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_secondSimpleArithmeticExpression
)
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_secondSimpleArithmeticExpression
)
.
')'
;
.
')'
;
}
}
...
@@ -45,11 +56,16 @@ class ModFunction extends FunctionNode
...
@@ -45,11 +56,16 @@ class ModFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
View file @
33fc28ff
...
@@ -24,30 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -24,30 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "SIZE" "(" CollectionValuedPathExpression ")"
* "SIZE" "(" CollectionValuedPathExpression ")"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SizeFunction
extends
FunctionNode
class
SizeFunction
extends
FunctionNode
{
{
private
$_collectionPathExpression
;
public
$collectionPathExpression
;
public
function
getCollectionPathExpression
()
{
return
$this
->
_collectionPathExpression
;
}
public
function
setCollectionPathExpression
(
$collPathExpr
)
{
$this
->
_collectionPathExpression
=
$collPathExpr
;
}
/**
/**
* @override
* @override
*/
*/
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
$dqlAlias
=
$this
->
_collectionPathExpression
->
getIdentificationVariable
()
;
$dqlAlias
=
$this
->
collectionPathExpression
->
identificationVariable
;
$qComp
=
$sqlWalker
->
getQueryComponent
(
$dqlAlias
);
$qComp
=
$sqlWalker
->
getQueryComponent
(
$dqlAlias
);
$parts
=
$this
->
_collectionPathExpression
->
getParts
()
;
$parts
=
$this
->
collectionPathExpression
->
parts
;
$assoc
=
$qComp
[
'metadata'
]
->
associationMappings
[
$parts
[
0
]];
$assoc
=
$qComp
[
'metadata'
]
->
associationMappings
[
$parts
[
0
]];
...
@@ -80,9 +76,12 @@ class SizeFunction extends FunctionNode
...
@@ -80,9 +76,12 @@ class SizeFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_collectionPathExpression
=
$parser
->
CollectionValuedPathExpression
();
$this
->
collectionPathExpression
=
$parser
->
CollectionValuedPathExpression
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "SQRT" "(" SimpleArithmeticExpression ")"
* "SQRT" "(" SimpleArithmeticExpression ")"
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SqrtFunction
extends
FunctionNode
class
SqrtFunction
extends
FunctionNode
{
{
private
$_simpleArithmeticExpression
;
public
$simpleArithmeticExpression
;
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
/**
/**
* @override
* @override
...
@@ -26,7 +42,7 @@ class SqrtFunction extends FunctionNode
...
@@ -26,7 +42,7 @@ class SqrtFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
return
'SQRT('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_
simpleArithmeticExpression
)
.
')'
;
return
'SQRT('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
simpleArithmeticExpression
)
.
')'
;
}
}
/**
/**
...
@@ -35,9 +51,12 @@ class SqrtFunction extends FunctionNode
...
@@ -35,9 +51,12 @@ class SqrtFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SubstringFunction
extends
FunctionNode
class
SubstringFunction
extends
FunctionNode
{
{
private
$_stringPrimary
;
public
$stringPrimary
;
private
$_firstSimpleArithmeticExpression
;
public
$firstSimpleArithmeticExpression
;
private
$_secondSimpleArithmeticExpression
;
public
$secondSimpleArithmeticExpression
;
public
function
geStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
function
getSecondSimpleArithmeticExpression
()
{
return
$this
->
_secondSimpleArithmeticExpression
;
}
public
function
getFirstSimpleArithmeticExpression
()
{
return
$this
->
_firstSimpleArithmeticExpression
;
}
/**
/**
* @override
* @override
...
@@ -38,14 +44,13 @@ class SubstringFunction extends FunctionNode
...
@@ -38,14 +44,13 @@ class SubstringFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
$sql
=
'SUBSTRING('
.
return
'SUBSTRING('
$sqlWalker
->
walkStringPrimary
(
$this
->
_
stringPrimary
)
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
', '
.
.
', '
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_
firstSimpleArithmeticExpression
)
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
firstSimpleArithmeticExpression
)
.
', '
.
.
', '
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_
secondSimpleArithmeticExpression
)
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
secondSimpleArithmeticExpression
)
.
')'
;
.
')'
;
return
$sql
;
}
}
/**
/**
...
@@ -54,14 +59,18 @@ class SubstringFunction extends FunctionNode
...
@@ -54,14 +59,18 @@ class SubstringFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
','
);
$parser
->
match
(
','
);
$this
->
_secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -11,60 +26,21 @@ use Doctrine\ORM\Query\Lexer;
...
@@ -11,60 +26,21 @@ use Doctrine\ORM\Query\Lexer;
/**
/**
* "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")"
* "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
TrimFunction
extends
FunctionNode
class
TrimFunction
extends
FunctionNode
{
{
private
$_leading
;
public
$leading
;
private
$_trailing
;
public
$trailing
;
private
$_both
;
public
$both
;
private
$_trimChar
;
public
$trimChar
;
private
$_stringPrimary
;
public
$stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
function
isLeading
()
{
return
$this
->
_leading
;
}
public
function
setLeading
(
$bool
)
{
$this
->
_leading
=
$bool
;
}
public
function
isTrailing
()
{
return
$this
->
_trailing
;
}
public
function
setTrailing
(
$bool
)
{
$this
->
_trailing
=
$bool
;
}
public
function
isBoth
()
{
return
$this
->
_both
;
}
public
function
setBoth
(
$bool
)
{
$this
->
_both
=
$bool
;
}
public
function
getTrimChar
()
{
return
$this
->
_trimChar
;
}
public
function
setTrimChar
(
$trimChar
)
{
$this
->
_trimChar
=
$trimChar
;
}
/**
/**
* @override
* @override
...
@@ -72,13 +48,20 @@ class TrimFunction extends FunctionNode
...
@@ -72,13 +48,20 @@ class TrimFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
$sql
=
'TRIM('
;
$sql
=
'TRIM('
;
if
(
$this
->
_leading
)
$sql
.=
'LEADING '
;
else
if
(
$this
->
_trailing
)
$sql
.=
'TRAILING '
;
if
(
$this
->
leading
)
{
else
if
(
$this
->
_both
)
$sql
.=
'BOTH '
;
$sql
.=
'LEADING '
;
if
(
$this
->
_trimChar
)
$sql
.=
$sqlWalker
->
getConnection
()
->
quote
(
$this
->
_trimChar
)
.
' '
;
}
else
if
(
$this
->
trailing
)
{
$sql
.=
'FROM '
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_stringPrimary
);
$sql
.=
'TRAILING '
;
$sql
.=
')'
;
}
else
if
(
$this
->
both
)
{
return
$sql
;
$sql
.=
'BOTH '
;
}
if
(
$this
->
trimChar
)
{
$sql
.=
$sqlWalker
->
getConnection
()
->
quote
(
$this
->
trimChar
)
.
' '
;
}
return
$sql
.
'FROM '
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
')'
;
}
}
/**
/**
...
@@ -87,30 +70,31 @@ class TrimFunction extends FunctionNode
...
@@ -87,30 +70,31 @@ class TrimFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
if
(
strcasecmp
(
'leading'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
if
(
strcasecmp
(
'leading'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
leading
=
true
;
$this
->
leading
=
true
;
}
else
if
(
strcasecmp
(
'trailing'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
}
else
if
(
strcasecmp
(
'trailing'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
trailing
=
true
;
$this
->
trailing
=
true
;
}
else
if
(
strcasecmp
(
'both'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
}
else
if
(
strcasecmp
(
'both'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
both
=
true
;
$this
->
both
=
true
;
}
}
if
(
$lexer
->
isNextToken
(
Lexer
::
T_STRING
))
{
if
(
$lexer
->
isNextToken
(
Lexer
::
T_STRING
))
{
$parser
->
match
(
Lexer
::
T_STRING
);
$parser
->
match
(
Lexer
::
T_STRING
);
$this
->
_
trimChar
=
$lexer
->
token
[
'value'
];
$this
->
trimChar
=
$lexer
->
token
[
'value'
];
}
}
if
(
$this
->
_leading
||
$this
->
_trailing
||
$this
->
_both
||
$this
->
_
trimChar
)
{
if
(
$this
->
leading
||
$this
->
trailing
||
$this
->
both
||
$this
->
trimChar
)
{
$parser
->
match
(
Lexer
::
T_FROM
);
$parser
->
match
(
Lexer
::
T_FROM
);
}
}
$this
->
_
stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST\Functions
;
namespace
Doctrine\ORM\Query\AST\Functions
;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
/**
* "UPPER" "(" StringPrimary ")"
* "UPPER" "(" StringPrimary ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
UpperFunction
extends
FunctionNode
class
UpperFunction
extends
FunctionNode
{
{
private
$_stringPrimary
;
public
$stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
/**
/**
* @override
* @override
...
@@ -26,7 +42,7 @@ class UpperFunction extends FunctionNode
...
@@ -26,7 +42,7 @@ class UpperFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
{
//TODO: Use platform to get SQL
//TODO: Use platform to get SQL
return
'UPPER('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_
stringPrimary
)
.
')'
;
return
'UPPER('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
')'
;
}
}
/**
/**
...
@@ -35,9 +51,12 @@ class UpperFunction extends FunctionNode
...
@@ -35,9 +51,12 @@ class UpperFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
{
$lexer
=
$parser
->
getLexer
();
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
$parser
->
match
(
')'
);
}
}
}
}
...
...
lib/Doctrine/ORM/Query/AST/GroupByClause.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Description of GroupByClause
* Description of GroupByClause
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
GroupByClause
extends
Node
class
GroupByClause
extends
Node
{
{
p
rivate
$_
groupByItems
=
array
();
p
ublic
$
groupByItems
=
array
();
public
function
__construct
(
array
$groupByItems
)
public
function
__construct
(
array
$groupByItems
)
{
{
$this
->
_groupByItems
=
$groupByItems
;
$this
->
groupByItems
=
$groupByItems
;
}
public
function
getGroupByItems
()
{
return
$this
->
_groupByItems
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/HavingClause.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Description of HavingClause
* Description of HavingClause
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
HavingClause
extends
Node
class
HavingClause
extends
Node
{
{
p
rivate
$_
conditionalExpression
;
p
ublic
$
conditionalExpression
;
public
function
__construct
(
$conditionalExpression
)
public
function
__construct
(
$conditionalExpression
)
{
{
$this
->
_conditionalExpression
=
$conditionalExpression
;
$this
->
conditionalExpression
=
$conditionalExpression
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php
View file @
33fc28ff
...
@@ -24,43 +24,25 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,43 +24,25 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
* IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
IdentificationVariableDeclaration
extends
Node
class
IdentificationVariableDeclaration
extends
Node
{
{
protected
$_rangeVariableDeclaration
=
null
;
public
$rangeVariableDeclaration
=
null
;
public
$indexBy
=
null
;
protected
$_indexBy
=
null
;
public
$joinVariableDeclarations
=
array
();
protected
$_joinVariableDeclarations
=
array
();
public
function
__construct
(
$rangeVariableDecl
,
$indexBy
,
array
$joinVariableDecls
)
public
function
__construct
(
$rangeVariableDecl
,
$indexBy
,
array
$joinVariableDecls
)
{
{
$this
->
_rangeVariableDeclaration
=
$rangeVariableDecl
;
$this
->
rangeVariableDeclaration
=
$rangeVariableDecl
;
$this
->
_indexBy
=
$indexBy
;
$this
->
indexBy
=
$indexBy
;
$this
->
_joinVariableDeclarations
=
$joinVariableDecls
;
$this
->
joinVariableDeclarations
=
$joinVariableDecls
;
}
/* Getters */
public
function
getRangeVariableDeclaration
()
{
return
$this
->
_rangeVariableDeclaration
;
}
public
function
getIndexBy
()
{
return
$this
->
_indexBy
;
}
public
function
getJoinVariableDeclarations
()
{
return
$this
->
_joinVariableDeclarations
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/InExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,53 +24,24 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,53 +24,24 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (Literal {"," Literal}* | Subselect) ")"
* InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (Literal {"," Literal}* | Subselect) ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
InExpression
extends
Node
class
InExpression
extends
Node
{
{
p
rivate
$_pathExpression
;
p
ublic
$not
;
p
rivate
$_not
=
false
;
p
ublic
$pathExpression
;
p
rivate
$_
literals
=
array
();
p
ublic
$
literals
=
array
();
p
rivate
$_
subselect
;
p
ublic
$
subselect
;
public
function
__construct
(
$pathExpression
)
public
function
__construct
(
$pathExpression
)
{
{
$this
->
_pathExpression
=
$pathExpression
;
$this
->
pathExpression
=
$pathExpression
;
}
public
function
setLiterals
(
array
$literals
)
{
$this
->
_literals
=
$literals
;
}
public
function
getLiterals
()
{
return
$this
->
_literals
;
}
public
function
setSubselect
(
$subselect
)
{
$this
->
_subselect
=
$subselect
;
}
public
function
getSubselect
()
{
return
$this
->
_subselect
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
public
function
getPathExpression
()
{
return
$this
->
_pathExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/IndexBy.php
View file @
33fc28ff
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
* IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
IndexBy
extends
Node
class
IndexBy
extends
Node
{
{
p
rotected
$_
simpleStateFieldPathExpression
=
null
;
p
ublic
$
simpleStateFieldPathExpression
=
null
;
public
function
__construct
(
$simpleStateFieldPathExpression
)
public
function
__construct
(
$simpleStateFieldPathExpression
)
{
{
$this
->
_simpleStateFieldPathExpression
=
$simpleStateFieldPathExpression
;
$this
->
simpleStateFieldPathExpression
=
$simpleStateFieldPathExpression
;
}
/* Getters */
public
function
getSimpleStateFieldPathExpression
()
{
return
$this
->
_simpleStateFieldPathExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/InputParameter.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,13 +24,18 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,13 +24,18 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Description of InputParameter
* Description of InputParameter
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
InputParameter
extends
Node
class
InputParameter
extends
Node
{
{
private
$_isNamed
;
public
$isNamed
;
private
$_position
;
public
$name
;
private
$_name
;
public
function
__construct
(
$value
)
public
function
__construct
(
$value
)
{
{
...
@@ -24,32 +44,8 @@ class InputParameter extends Node
...
@@ -24,32 +44,8 @@ class InputParameter extends Node
}
}
$param
=
substr
(
$value
,
1
);
$param
=
substr
(
$value
,
1
);
$this
->
_isNamed
=
!
is_numeric
(
$param
);
$this
->
isNamed
=
!
is_numeric
(
$param
);
if
(
$this
->
_isNamed
)
{
$this
->
name
=
$param
;
$this
->
_name
=
$param
;
}
else
{
$this
->
_position
=
$param
;
}
}
public
function
isNamed
()
{
return
$this
->
_isNamed
;
}
public
function
isPositional
()
{
return
!
$this
->
_isNamed
;
}
public
function
getName
()
{
return
$this
->
_name
;
}
public
function
getPosition
()
{
return
$this
->
_position
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Join.php
View file @
33fc28ff
...
@@ -25,11 +25,13 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -25,11 +25,13 @@ namespace Doctrine\ORM\Query\AST;
* Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
* Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
* ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
* ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
Join
extends
Node
class
Join
extends
Node
{
{
...
@@ -39,55 +41,17 @@ class Join extends Node
...
@@ -39,55 +41,17 @@ class Join extends Node
const
JOIN_WHERE_ON
=
1
;
const
JOIN_WHERE_ON
=
1
;
const
JOIN_WHERE_WITH
=
2
;
const
JOIN_WHERE_WITH
=
2
;
p
rotected
$_
joinType
=
self
::
JOIN_TYPE_INNER
;
p
ublic
$
joinType
=
self
::
JOIN_TYPE_INNER
;
p
rotected
$_
joinAssociationPathExpression
=
null
;
p
ublic
$
joinAssociationPathExpression
=
null
;
p
rotected
$_
aliasIdentificationVariable
=
null
;
p
ublic
$
aliasIdentificationVariable
=
null
;
p
rotected
$_
whereType
=
self
::
JOIN_WHERE_WITH
;
p
ublic
$
whereType
=
self
::
JOIN_WHERE_WITH
;
p
rotected
$_
conditionalExpression
=
null
;
p
ublic
$
conditionalExpression
=
null
;
public
function
__construct
(
$joinType
,
$joinAssocPathExpr
,
$aliasIdentVar
)
public
function
__construct
(
$joinType
,
$joinAssocPathExpr
,
$aliasIdentVar
)
{
{
$this
->
_joinType
=
$joinType
;
$this
->
joinType
=
$joinType
;
$this
->
_joinAssociationPathExpression
=
$joinAssocPathExpr
;
$this
->
joinAssociationPathExpression
=
$joinAssocPathExpr
;
$this
->
_aliasIdentificationVariable
=
$aliasIdentVar
;
$this
->
aliasIdentificationVariable
=
$aliasIdentVar
;
}
/* Setters */
public
function
setWhereType
(
$whereType
)
{
$this
->
_whereType
=
$whereType
;
}
public
function
setConditionalExpression
(
$conditionalExpression
)
{
$this
->
_conditionalExpression
=
$conditionalExpression
;
}
/* Getters */
public
function
getJoinType
()
{
return
$this
->
_joinType
;
}
public
function
getJoinAssociationPathExpression
()
{
return
$this
->
_joinAssociationPathExpression
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
getWhereType
()
{
return
$this
->
_whereType
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php
View file @
33fc28ff
<?php
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* JoinAssociationPathExpression ::= IdentificationVariable "." (SingleValuedAssociationField | CollectionValuedAssociationField)
* JoinAssociationPathExpression ::= IdentificationVariable "." (SingleValuedAssociationField | CollectionValuedAssociationField)
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Roman Borschel
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
JoinAssociationPathExpression
extends
Node
class
JoinAssociationPathExpression
extends
Node
{
{
private
$_identificationVariable
;
public
$identificationVariable
;
private
$_assocField
;
public
$associationField
;
public
function
__construct
(
$identificationVariable
,
$assocField
)
{
$this
->
_identificationVariable
=
$identificationVariable
;
$this
->
_assocField
=
$assocField
;
}
public
function
getIdentificationVariable
()
{
return
$this
->
_identificationVariable
;
}
public
function
getAssociationField
(
)
public
function
__construct
(
$identificationVariable
,
$associationField
)
{
{
return
$this
->
_assocField
;
$this
->
identificationVariable
=
$identificationVariable
;
$this
->
associationField
=
$associationField
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php
View file @
33fc28ff
...
@@ -24,32 +24,23 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,32 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* JoinVariableDeclaration ::= Join [IndexBy]
* JoinVariableDeclaration ::= Join [IndexBy]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
JoinVariableDeclaration
extends
Node
class
JoinVariableDeclaration
extends
Node
{
{
p
rotected
$_
join
=
null
;
p
ublic
$
join
=
null
;
p
rotected
$_
indexBy
=
null
;
p
ublic
$
indexBy
=
null
;
public
function
__construct
(
$join
,
$indexBy
)
public
function
__construct
(
$join
,
$indexBy
)
{
{
$this
->
_join
=
$join
;
$this
->
join
=
$join
;
$this
->
_indexBy
=
$indexBy
;
$this
->
indexBy
=
$indexBy
;
}
/* Getters */
public
function
getJoin
()
{
return
$this
->
_join
;
}
public
function
getIndexBy
()
{
return
$this
->
_indexBy
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/LikeExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,41 +24,26 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,41 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* LikeExpression ::= StringExpression ["NOT"] "LIKE" string ["ESCAPE" char]
* LikeExpression ::= StringExpression ["NOT"] "LIKE" string ["ESCAPE" char]
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
LikeExpression
extends
Node
class
LikeExpression
extends
Node
{
{
private
$_stringExpr
;
public
$not
;
private
$_isNot
;
public
$stringExpression
;
private
$_stringPattern
;
public
$stringPattern
;
private
$_escapeChar
;
public
$escapeChar
;
public
function
__construct
(
$stringExpr
,
$stringPattern
,
$isNot
=
false
,
$escapeChar
=
null
)
{
$this
->
_stringExpr
=
$stringExpr
;
$this
->
_stringPattern
=
$stringPattern
;
$this
->
_isNot
=
$isNot
;
$this
->
_escapeChar
=
$escapeChar
;
}
public
function
isNot
()
{
return
$this
->
_isNot
;
}
public
function
getStringExpression
()
{
return
$this
->
_stringExpr
;
}
public
function
getStringPattern
()
{
return
$this
->
_stringPattern
;
}
public
function
getEscapeChar
(
)
public
function
__construct
(
$stringExpression
,
$stringPattern
,
$escapeChar
=
null
)
{
{
return
$this
->
_escapeChar
;
$this
->
stringExpression
=
$stringExpression
;
$this
->
stringPattern
=
$stringPattern
;
$this
->
escapeChar
=
$escapeChar
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Node.php
View file @
33fc28ff
...
@@ -24,13 +24,13 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,13 +24,13 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Abstract class of an AST node
* Abstract class of an AST node
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
abstract
class
Node
abstract
class
Node
{
{
...
...
lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL"
* NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
NullComparisonExpression
extends
Node
class
NullComparisonExpression
extends
Node
{
{
p
rivate
$_expression
;
p
ublic
$not
;
p
rivate
$_not
;
p
ublic
$expression
;
public
function
__construct
(
$expression
)
public
function
__construct
(
$expression
)
{
{
$this
->
_expression
=
$expression
;
$this
->
expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/OrderByClause.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
* OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
OrderByClause
extends
Node
class
OrderByClause
extends
Node
{
{
p
rivate
$_
orderByItems
=
array
();
p
ublic
$
orderByItems
=
array
();
public
function
__construct
(
array
$orderByItems
)
public
function
__construct
(
array
$orderByItems
)
{
{
$this
->
_orderByItems
=
$orderByItems
;
$this
->
orderByItems
=
$orderByItems
;
}
public
function
getOrderByItems
()
{
return
$this
->
_orderByItems
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/OrderByItem.php
View file @
33fc28ff
...
@@ -22,48 +22,34 @@
...
@@ -22,48 +22,34 @@
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* AST node for the following grammar rule:
*
* OrderByItem ::= (ResultVariable | StateFieldPathExpression) ["ASC" | "DESC"]
* OrderByItem ::= (ResultVariable | StateFieldPathExpression) ["ASC" | "DESC"]
*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
*/
class
OrderByItem
extends
Node
class
OrderByItem
extends
Node
{
{
private
$_expr
;
public
$expression
;
private
$_asc
;
public
$type
;
private
$_desc
;
public
function
__construct
(
$expr
)
{
$this
->
_expr
=
$expr
;
}
public
function
getExpression
(
)
public
function
__construct
(
$expression
)
{
{
return
$this
->
_expr
;
$this
->
expression
=
$expression
;
}
public
function
setAsc
(
$bool
)
{
$this
->
_asc
=
$bool
;
}
}
public
function
isAsc
()
public
function
isAsc
()
{
{
return
$this
->
_asc
;
return
strtoupper
(
$this
->
type
)
==
'ASC'
;
}
public
function
setDesc
(
$bool
)
{
$this
->
_desc
=
$bool
;
}
}
public
function
isDesc
()
public
function
isDesc
()
{
{
return
$this
->
_desc
;
return
strtoupper
(
$this
->
type
)
==
'DESC'
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/PathExpression.php
View file @
33fc28ff
<?php
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* AST node for the following path expressions:
*
* AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression
* AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression
*
* SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression
* SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression
*
* StateFieldPathExpression ::= SimpleStateFieldPathExpression | SimpleStateFieldAssociationPathExpression
* StateFieldPathExpression ::= SimpleStateFieldPathExpression | SimpleStateFieldAssociationPathExpression
*
* SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
* SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
*
* CollectionValuedPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* CollectionValuedAssociationField
* CollectionValuedPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* CollectionValuedAssociationField
*
* StateField ::= {EmbeddedClassStateField "."}* SimpleStateField
* StateField ::= {EmbeddedClassStateField "."}* SimpleStateField
*
* SimpleStateFieldPathExpression ::= IdentificationVariable "." StateField
* SimpleStateFieldPathExpression ::= IdentificationVariable "." StateField
*
* SimpleStateFieldAssociationPathExpression ::= SingleValuedAssociationPathExpression "." StateField
* SimpleStateFieldAssociationPathExpression ::= SingleValuedAssociationPathExpression "." StateField
*
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
PathExpression
extends
Node
class
PathExpression
extends
Node
{
{
...
@@ -30,54 +45,21 @@ class PathExpression extends Node
...
@@ -30,54 +45,21 @@ class PathExpression extends Node
const
TYPE_SINGLE_VALUED_ASSOCIATION
=
4
;
const
TYPE_SINGLE_VALUED_ASSOCIATION
=
4
;
const
TYPE_STATE_FIELD
=
8
;
const
TYPE_STATE_FIELD
=
8
;
p
rivate
$_
type
;
p
ublic
$
type
;
p
rivate
$_
expectedType
;
p
ublic
$
expectedType
;
p
rivate
$_
identificationVariable
;
p
ublic
$
identificationVariable
;
p
rivate
$_
parts
;
p
ublic
$
parts
;
public
function
__construct
(
$expectedType
,
$identificationVariable
,
array
$parts
)
public
function
__construct
(
$expectedType
,
$identificationVariable
,
array
$parts
)
{
{
$this
->
_expectedType
=
$expectedType
;
$this
->
expectedType
=
$expectedType
;
$this
->
_identificationVariable
=
$identificationVariable
;
$this
->
identificationVariable
=
$identificationVariable
;
$this
->
_parts
=
$parts
;
$this
->
parts
=
$parts
;
}
public
function
getIdentificationVariable
()
{
return
$this
->
_identificationVariable
;
}
public
function
getParts
()
{
return
$this
->
_parts
;
}
public
function
setExpectedType
(
$type
)
{
$this
->
_expectedType
;
}
public
function
getExpectedType
()
{
return
$this
->
_expectedType
;
}
/**
* INTERNAL
*/
public
function
setType
(
$type
)
{
$this
->
_type
=
$type
;
}
public
function
getType
()
{
return
$this
->
_type
;
}
}
public
function
dispatch
(
$walker
)
public
function
dispatch
(
$walker
)
{
{
switch
(
$this
->
_
type
)
{
switch
(
$this
->
type
)
{
case
self
::
TYPE_STATE_FIELD
:
case
self
::
TYPE_STATE_FIELD
:
return
$walker
->
walkStateFieldPathExpression
(
$this
);
return
$walker
->
walkStateFieldPathExpression
(
$this
);
case
self
::
TYPE_SINGLE_VALUED_ASSOCIATION
:
case
self
::
TYPE_SINGLE_VALUED_ASSOCIATION
:
...
...
lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,18 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,18 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
* QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
QuantifiedExpression
extends
Node
class
QuantifiedExpression
extends
Node
{
{
private
$_all
;
public
$type
;
private
$_any
;
public
$subselect
;
private
$_some
;
private
$_subselect
;
public
function
__construct
(
$subselect
)
public
function
__construct
(
$subselect
)
{
{
$this
->
_
subselect
=
$subselect
;
$this
->
subselect
=
$subselect
;
}
}
public
function
getSubselect
()
public
function
getSubselect
()
...
@@ -30,32 +49,17 @@ class QuantifiedExpression extends Node
...
@@ -30,32 +49,17 @@ class QuantifiedExpression extends Node
public
function
isAll
()
public
function
isAll
()
{
{
return
$this
->
_all
;
return
strtoupper
(
$this
->
type
)
==
'ALL'
;
}
}
public
function
isAny
()
public
function
isAny
()
{
{
return
$this
->
_any
;
return
strtoupper
(
$this
->
type
)
==
'ANY'
;
}
}
public
function
isSome
()
public
function
isSome
()
{
{
return
$this
->
_some
;
return
strtoupper
(
$this
->
type
)
==
'SOME'
;
}
public
function
setAll
(
$bool
)
{
$this
->
_all
=
$bool
;
}
public
function
setAny
(
$bool
)
{
$this
->
_any
=
$bool
;
}
public
function
setSome
(
$bool
)
{
$this
->
_some
=
$bool
;
}
}
/**
/**
...
...
lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php
View file @
33fc28ff
...
@@ -24,39 +24,25 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,39 +24,25 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
* RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
RangeVariableDeclaration
extends
Node
class
RangeVariableDeclaration
extends
Node
{
{
p
rivate
$_
classMetadata
;
p
ublic
$
classMetadata
;
p
rivate
$_
abstractSchemaName
;
p
ublic
$
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
ublic
$
aliasIdentificationVariable
;
public
function
__construct
(
$classMetadata
,
$aliasIdentificationVar
)
public
function
__construct
(
$classMetadata
,
$aliasIdentificationVar
)
{
{
$this
->
_classMetadata
=
$classMetadata
;
$this
->
classMetadata
=
$classMetadata
;
$this
->
_abstractSchemaName
=
$classMetadata
->
name
;
$this
->
abstractSchemaName
=
$classMetadata
->
name
;
$this
->
_aliasIdentificationVariable
=
$aliasIdentificationVar
;
$this
->
aliasIdentificationVariable
=
$aliasIdentificationVar
;
}
/* Getters */
public
function
getAbstractSchemaName
()
{
return
$this
->
_abstractSchemaName
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
getClassMetadata
()
{
return
$this
->
_classMetadata
;
}
}
public
function
dispatch
(
$walker
)
public
function
dispatch
(
$walker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectClause.php
View file @
33fc28ff
...
@@ -24,50 +24,23 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,50 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SelectClause
extends
Node
class
SelectClause
extends
Node
{
{
protected
$_isDistinct
;
public
$isDistinct
;
public
$selectExpressions
=
array
();
protected
$_selectExpressions
=
array
();
public
function
__construct
(
array
$selectExpressions
,
$isDistinct
)
public
function
__construct
(
array
$selectExpressions
,
$isDistinct
)
{
{
$this
->
_isDistinct
=
$isDistinct
;
$this
->
isDistinct
=
$isDistinct
;
$this
->
_selectExpressions
=
$selectExpressions
;
$this
->
selectExpressions
=
$selectExpressions
;
}
/* Getters */
public
function
isDistinct
()
{
return
$this
->
_isDistinct
;
}
public
function
getSelectExpressions
()
{
return
$this
->
_selectExpressions
;
}
/* REMOVE ME LATER. COPIED METHODS FROM SPLIT OF PRODUCTION INTO "AST" AND "PARSER" */
public
function
buildSql
()
{
return
'SELECT '
.
((
$this
->
_isDistinct
)
?
'DISTINCT '
:
''
)
.
implode
(
', '
,
$this
->
_mapSelectExpressions
());
}
protected
function
_mapSelectExpressions
()
{
return
array_map
(
array
(
&
$this
,
'_mapSelectExpression'
),
$this
->
_selectExpressions
);
}
protected
function
_mapSelectExpression
(
$value
)
{
return
is_object
(
$value
)
?
$value
->
buildSql
()
:
$value
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectExpression.php
View file @
33fc28ff
...
@@ -25,32 +25,23 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -25,32 +25,23 @@ namespace Doctrine\ORM\Query\AST;
* SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
* SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SelectExpression
extends
Node
class
SelectExpression
extends
Node
{
{
p
rotected
$_
expression
;
p
ublic
$
expression
;
p
rotected
$_
fieldIdentificationVariable
;
p
ublic
$
fieldIdentificationVariable
;
public
function
__construct
(
$expression
,
$fieldIdentificationVariable
)
public
function
__construct
(
$expression
,
$fieldIdentificationVariable
)
{
{
$this
->
_expression
=
$expression
;
$this
->
expression
=
$expression
;
$this
->
_fieldIdentificationVariable
=
$fieldIdentificationVariable
;
$this
->
fieldIdentificationVariable
=
$fieldIdentificationVariable
;
}
/* Getters */
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
getFieldIdentificationVariable
()
{
return
$this
->
_fieldIdentificationVariable
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectStatement.php
View file @
33fc28ff
...
@@ -24,60 +24,26 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,60 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
* SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SelectStatement
extends
Node
class
SelectStatement
extends
Node
{
{
protected
$_selectClause
;
public
$selectClause
;
protected
$_fromClause
;
public
$fromClause
;
protected
$_whereClause
;
public
$whereClause
;
protected
$_groupByClause
;
public
$groupByClause
;
protected
$_havingClause
;
public
$havingClause
;
protected
$_orderByClause
;
public
$orderByClause
;
public
function
__construct
(
$selectClause
,
$fromClause
,
$whereClause
,
$groupByClause
,
public
function
__construct
(
$selectClause
,
$fromClause
)
{
$havingClause
,
$orderByClause
)
{
$this
->
selectClause
=
$selectClause
;
$this
->
_selectClause
=
$selectClause
;
$this
->
fromClause
=
$fromClause
;
$this
->
_fromClause
=
$fromClause
;
$this
->
_whereClause
=
$whereClause
;
$this
->
_groupByClause
=
$groupByClause
;
$this
->
_havingClause
=
$havingClause
;
$this
->
_orderByClause
=
$orderByClause
;
}
/* Getters */
public
function
getSelectClause
()
{
return
$this
->
_selectClause
;
}
public
function
getFromClause
()
{
return
$this
->
_fromClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
}
public
function
getGroupByClause
()
{
return
$this
->
_groupByClause
;
}
public
function
getHavingClause
()
{
return
$this
->
_havingClause
;
}
public
function
getOrderByClause
()
{
return
$this
->
_orderByClause
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
* SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SimpleArithmeticExpression
extends
Node
class
SimpleArithmeticExpression
extends
Node
{
{
p
rivate
$_terms
;
p
ublic
$arithmeticTerms
=
array
()
;
public
function
__construct
(
array
$arithmeticTerms
)
public
function
__construct
(
array
$arithmeticTerms
)
{
{
$this
->
_terms
=
$arithmeticTerms
;
$this
->
arithmeticTerms
=
$arithmeticTerms
;
}
public
function
getArithmeticTerms
()
{
return
$this
->
_terms
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php
View file @
33fc28ff
...
@@ -24,36 +24,23 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,36 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
* SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SimpleSelectClause
extends
Node
class
SimpleSelectClause
extends
Node
{
{
private
$_isDistinct
=
false
;
public
$isDistinct
=
false
;
private
$_simpleSelectExpression
;
public
$simpleSelectExpression
;
public
function
__construct
(
$simpleSelectExpression
)
{
$this
->
_simpleSelectExpression
=
$simpleSelectExpression
;
}
/* Getters */
public
function
isDistinct
()
{
return
$this
->
_isDistinct
;
}
public
function
setDistinct
(
$bool
)
{
$this
->
_isDistinct
=
$bool
;
}
public
function
getSimpleSelectExpression
(
)
public
function
__construct
(
$simpleSelectExpression
,
$isDistinct
)
{
{
return
$this
->
_simpleSelectExpression
;
$this
->
simpleSelectExpression
=
$simpleSelectExpression
;
$this
->
isDistinct
=
$isDistinct
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php
View file @
33fc28ff
...
@@ -25,35 +25,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -25,35 +25,22 @@ namespace Doctrine\ORM\Query\AST;
* SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable
* SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable
* | (AggregateExpression [["AS"] FieldAliasIdentificationVariable])
* | (AggregateExpression [["AS"] FieldAliasIdentificationVariable])
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SimpleSelectExpression
extends
Node
class
SimpleSelectExpression
extends
Node
{
{
p
rivate
$_
expression
;
p
ublic
$
expression
;
p
rivate
$_
fieldIdentificationVariable
;
p
ublic
$
fieldIdentificationVariable
;
public
function
__construct
(
$expression
)
public
function
__construct
(
$expression
)
{
{
$this
->
_expression
=
$expression
;
$this
->
expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
getFieldIdentificationVariable
()
{
return
$this
->
_fieldIdentificationVariable
;
}
public
function
setFieldIdentificationVariable
(
$fieldAlias
)
{
$this
->
_fieldIdentificationVariable
=
$fieldAlias
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Subselect.php
View file @
33fc28ff
...
@@ -24,76 +24,27 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,76 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
Subselect
extends
Node
class
Subselect
extends
Node
{
{
p
rivate
$_
simpleSelectClause
;
p
ublic
$
simpleSelectClause
;
p
rivate
$_
subselectFromClause
;
p
ublic
$
subselectFromClause
;
p
rivate
$_
whereClause
;
p
ublic
$
whereClause
;
p
rivate
$_
groupByClause
;
p
ublic
$
groupByClause
;
p
rivate
$_
havingClause
;
p
ublic
$
havingClause
;
p
rivate
$_
orderByClause
;
p
ublic
$
orderByClause
;
public
function
__construct
(
$simpleSelectClause
,
$subselectFromClause
)
public
function
__construct
(
$simpleSelectClause
,
$subselectFromClause
)
{
{
$this
->
_simpleSelectClause
=
$simpleSelectClause
;
$this
->
simpleSelectClause
=
$simpleSelectClause
;
$this
->
_subselectFromClause
=
$subselectFromClause
;
$this
->
subselectFromClause
=
$subselectFromClause
;
}
/* Getters */
public
function
getSimpleSelectClause
()
{
return
$this
->
_simpleSelectClause
;
}
public
function
getSubselectFromClause
()
{
return
$this
->
_subselectFromClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
}
public
function
setWhereClause
(
$whereClause
)
{
$this
->
_whereClause
=
$whereClause
;
}
public
function
getGroupByClause
()
{
return
$this
->
_groupByClause
;
}
public
function
setGroupByClause
(
$groupByClause
)
{
$this
->
_groupByClause
=
$groupByClause
;
}
public
function
getHavingClause
()
{
return
$this
->
_havingClause
;
}
public
function
setHavingClause
(
$havingClause
)
{
$this
->
_havingClause
=
$havingClause
;
}
public
function
getOrderByClause
()
{
return
$this
->
_orderByClause
;
}
public
function
setOrderByClause
(
$orderByClause
)
{
$this
->
_orderByClause
=
$orderByClause
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SubselectFromClause.php
View file @
33fc28ff
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*
* SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
SubselectFromClause
extends
Node
class
SubselectFromClause
extends
Node
{
{
p
rivate
$_
identificationVariableDeclarations
=
array
();
p
ublic
$
identificationVariableDeclarations
=
array
();
public
function
__construct
(
array
$identificationVariableDeclarations
)
public
function
__construct
(
array
$identificationVariableDeclarations
)
{
{
$this
->
_identificationVariableDeclarations
=
$identificationVariableDeclarations
;
$this
->
identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
/* Getters */
public
function
getSubselectIdentificationVariableDeclarations
()
{
return
$this
->
_identificationVariableDeclarations
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateClause.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
* UpdateClause ::= "UPDATE" AbstractSchemaName [["AS"] AliasIdentificationVariable] "SET" UpdateItem {"," UpdateItem}*
* UpdateClause ::= "UPDATE" AbstractSchemaName [["AS"] AliasIdentificationVariable] "SET" UpdateItem {"," UpdateItem}*
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
UpdateClause
extends
Node
class
UpdateClause
extends
Node
{
{
p
rivate
$_
abstractSchemaName
;
p
ublic
$
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
ublic
$
aliasIdentificationVariable
;
p
rivate
$_
updateItems
=
array
();
p
ublic
$
updateItems
=
array
();
public
function
__construct
(
$abstractSchemaName
,
array
$updateItems
)
public
function
__construct
(
$abstractSchemaName
,
array
$updateItems
)
{
{
$this
->
_abstractSchemaName
=
$abstractSchemaName
;
$this
->
abstractSchemaName
=
$abstractSchemaName
;
$this
->
_updateItems
=
$updateItems
;
$this
->
updateItems
=
$updateItems
;
}
public
function
getAbstractSchemaName
()
{
return
$this
->
_abstractSchemaName
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
setAliasIdentificationVariable
(
$alias
)
{
$this
->
_aliasIdentificationVariable
=
$alias
;
}
public
function
getUpdateItems
()
{
return
$this
->
_updateItems
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateItem.php
View file @
33fc28ff
...
@@ -26,39 +26,24 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -26,39 +26,24 @@ namespace Doctrine\ORM\Query\AST;
* NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary |
* NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary |
* EnumPrimary | SimpleEntityExpression | "NULL"
* EnumPrimary | SimpleEntityExpression | "NULL"
*
*
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
UpdateItem
extends
Node
class
UpdateItem
extends
Node
{
{
p
rivate
$_
identificationVariable
;
p
ublic
$
identificationVariable
;
p
rivate
$_
field
;
p
ublic
$
field
;
p
rivate
$_
newValue
;
p
ublic
$
newValue
;
public
function
__construct
(
$field
,
$newValue
)
public
function
__construct
(
$field
,
$newValue
)
{
{
$this
->
_field
=
$field
;
$this
->
field
=
$field
;
$this
->
_newValue
=
$newValue
;
$this
->
newValue
=
$newValue
;
}
public
function
setIdentificationVariable
(
$identVar
)
{
$this
->
_identificationVariable
=
$identVar
;
}
public
function
getIdentificationVariable
()
{
return
$this
->
_identificationVariable
;
}
public
function
getField
()
{
return
$this
->
_field
;
}
public
function
getNewValue
()
{
return
$this
->
_newValue
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateStatement.php
View file @
33fc28ff
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
/**
* UpdateStatement = UpdateClause [WhereClause]
* UpdateStatement = UpdateClause [WhereClause]
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
UpdateStatement
extends
Node
class
UpdateStatement
extends
Node
{
{
p
rivate
$_
updateClause
;
p
ublic
$
updateClause
;
p
rivate
$_
whereClause
;
p
ublic
$
whereClause
;
public
function
__construct
(
$updateClause
)
public
function
__construct
(
$updateClause
)
{
{
$this
->
_updateClause
=
$updateClause
;
$this
->
updateClause
=
$updateClause
;
}
public
function
setWhereClause
(
$whereClause
)
{
$this
->
_whereClause
=
$whereClause
;
}
public
function
getUpdateClause
()
{
return
$this
->
_updateClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/WhereClause.php
View file @
33fc28ff
<?php
<?php
/*
/*
* To change this template, choose Tools | Templates
* $Id$
* and open the template in the editor.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace
Doctrine\ORM\Query\AST
;
namespace
Doctrine\ORM\Query\AST
;
/**
/**
*
Description of WhereClause
*
WhereClause ::= "WHERE" ConditionalExpression
*
*
* @author robo
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
*/
class
WhereClause
extends
Node
class
WhereClause
extends
Node
{
{
p
rivate
$_
conditionalExpression
;
p
ublic
$
conditionalExpression
;
public
function
__construct
(
$conditionalExpression
)
public
function
__construct
(
$conditionalExpression
)
{
{
$this
->
_conditionalExpression
=
$conditionalExpression
;
$this
->
conditionalExpression
=
$conditionalExpression
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
}
}
public
function
dispatch
(
$sqlWalker
)
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
View file @
33fc28ff
...
@@ -53,9 +53,9 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
...
@@ -53,9 +53,9 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$conn
=
$em
->
getConnection
();
$conn
=
$em
->
getConnection
();
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$AST
->
getDeleteClause
()
->
getAbstractSchemaName
()
$AST
->
deleteClause
->
abstractSchemaName
);
);
$primaryDqlAlias
=
$AST
->
getDeleteClause
()
->
getAliasIdentificationVariable
()
;
$primaryDqlAlias
=
$AST
->
deleteClause
->
aliasIdentificationVariable
;
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
...
@@ -71,8 +71,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
...
@@ -71,8 +71,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
// Append WHERE clause, if there is one.
// Append WHERE clause, if there is one.
if
(
$AST
->
getWhereClause
()
)
{
if
(
$AST
->
whereClause
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
getWhereClause
()
);
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
whereClause
);
}
}
// 2. Create ID subselect statement used in DELETE .... WHERE ... IN (subselect)
// 2. Create ID subselect statement used in DELETE .... WHERE ... IN (subselect)
...
...
lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php
View file @
33fc28ff
...
@@ -53,13 +53,12 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
...
@@ -53,13 +53,12 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
{
{
$em
=
$sqlWalker
->
getEntityManager
();
$em
=
$sqlWalker
->
getEntityManager
();
$conn
=
$em
->
getConnection
();
$conn
=
$em
->
getConnection
();
$updateClause
=
$AST
->
updateClause
;
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$updateClause
->
abstractSchemaName
);
$AST
->
getUpdateClause
()
->
getAbstractSchemaName
()
);
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$updateItems
=
$
AST
->
getUpdateClause
()
->
getUpdateItems
()
;
$updateItems
=
$
updateClause
->
updateItems
;
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
$idColumnNames
=
$rootClass
->
getIdentifierColumnNames
();
$idColumnNames
=
$rootClass
->
getIdentifierColumnNames
();
...
@@ -68,8 +67,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
...
@@ -68,8 +67,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
// 1. Create an INSERT INTO temptable ... SELECT identifiers WHERE $AST->getWhereClause()
// 1. Create an INSERT INTO temptable ... SELECT identifiers WHERE $AST->getWhereClause()
$this
->
_insertSql
=
'INSERT INTO '
.
$tempTable
.
' ('
.
$idColumnList
.
')'
$this
->
_insertSql
=
'INSERT INTO '
.
$tempTable
.
' ('
.
$idColumnList
.
')'
.
' SELECT t0.'
.
implode
(
', t0.'
,
$idColumnNames
);
.
' SELECT t0.'
.
implode
(
', t0.'
,
$idColumnNames
);
$sqlWalker
->
setSqlTableAlias
(
$primaryClass
->
primaryTable
[
'name'
]
.
$
AST
->
getUpdateClause
()
->
getAliasIdentificationVariable
()
,
't0'
);
$sqlWalker
->
setSqlTableAlias
(
$primaryClass
->
primaryTable
[
'name'
]
.
$
updateClause
->
aliasIdentificationVariable
,
't0'
);
$rangeDecl
=
new
AST\RangeVariableDeclaration
(
$primaryClass
,
$
AST
->
getUpdateClause
()
->
getAliasIdentificationVariable
()
);
$rangeDecl
=
new
AST\RangeVariableDeclaration
(
$primaryClass
,
$
updateClause
->
aliasIdentificationVariable
);
$fromClause
=
new
AST\FromClause
(
array
(
new
AST\IdentificationVariableDeclaration
(
$rangeDecl
,
null
,
array
())));
$fromClause
=
new
AST\FromClause
(
array
(
new
AST\IdentificationVariableDeclaration
(
$rangeDecl
,
null
,
array
())));
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
...
@@ -79,6 +78,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
...
@@ -79,6 +78,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
// 3. Create and store UPDATE statements
// 3. Create and store UPDATE statements
$classNames
=
array_merge
(
$primaryClass
->
parentClasses
,
array
(
$primaryClass
->
name
),
$primaryClass
->
subClasses
);
$classNames
=
array_merge
(
$primaryClass
->
parentClasses
,
array
(
$primaryClass
->
name
),
$primaryClass
->
subClasses
);
$i
=
-
1
;
$i
=
-
1
;
foreach
(
array_reverse
(
$classNames
)
as
$className
)
{
foreach
(
array_reverse
(
$classNames
)
as
$className
)
{
$affected
=
false
;
$affected
=
false
;
$class
=
$em
->
getClassMetadata
(
$className
);
$class
=
$em
->
getClassMetadata
(
$className
);
...
@@ -86,19 +86,22 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
...
@@ -86,19 +86,22 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
$updateSql
=
'UPDATE '
.
$conn
->
quoteIdentifier
(
$tableName
)
.
' SET '
;
$updateSql
=
'UPDATE '
.
$conn
->
quoteIdentifier
(
$tableName
)
.
' SET '
;
foreach
(
$updateItems
as
$updateItem
)
{
foreach
(
$updateItems
as
$updateItem
)
{
$field
=
$updateItem
->
getField
()
;
$field
=
$updateItem
->
field
;
if
(
isset
(
$class
->
fieldMappings
[
$field
])
&&
!
isset
(
$class
->
fieldMappings
[
$field
][
'inherited'
]))
{
if
(
isset
(
$class
->
fieldMappings
[
$field
])
&&
!
isset
(
$class
->
fieldMappings
[
$field
][
'inherited'
]))
{
$newValue
=
$updateItem
->
getNewValue
();
$newValue
=
$updateItem
->
newValue
;
if
(
!
$affected
)
{
if
(
!
$affected
)
{
$affected
=
true
;
$affected
=
true
;
++
$i
;
++
$i
;
}
else
{
}
else
{
$updateSql
.=
', '
;
$updateSql
.=
', '
;
}
}
$updateSql
.=
$sqlWalker
->
walkUpdateItem
(
$updateItem
);
$updateSql
.=
$sqlWalker
->
walkUpdateItem
(
$updateItem
);
//FIXME: parameters can be more deeply nested. traverse the tree.
//FIXME: parameters can be more deeply nested. traverse the tree.
if
(
$newValue
instanceof
AST\InputParameter
)
{
if
(
$newValue
instanceof
AST\InputParameter
)
{
$paramKey
=
$newValue
->
isNamed
()
?
$newValue
->
getName
()
:
$newValue
->
getPosition
()
;
$paramKey
=
$newValue
->
name
;
$this
->
_sqlParameters
[
$i
][]
=
$sqlWalker
->
getQuery
()
->
getParameter
(
$paramKey
);
$this
->
_sqlParameters
[
$i
][]
=
$sqlWalker
->
getQuery
()
->
getParameter
(
$paramKey
);
++
$this
->
_numParametersInUpdateClause
;
++
$this
->
_numParametersInUpdateClause
;
}
}
...
@@ -111,8 +114,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
...
@@ -111,8 +114,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
}
}
// Append WHERE clause to insertSql, if there is one.
// Append WHERE clause to insertSql, if there is one.
if
(
$AST
->
getWhereClause
()
)
{
if
(
$AST
->
whereClause
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
getWhereClause
()
);
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
whereClause
);
}
}
// 4. Store DDL for temporary identifier table.
// 4. Store DDL for temporary identifier table.
...
...
lib/Doctrine/ORM/Query/Parser.php
View file @
33fc28ff
...
@@ -30,13 +30,14 @@ use Doctrine\Common\DoctrineException,
...
@@ -30,13 +30,14 @@ use Doctrine\Common\DoctrineException,
* An LL(*) parser for the context-free grammar of the Doctrine Query Language.
* An LL(*) parser for the context-free grammar of the Doctrine Query Language.
* Parses a DQL query, reports any errors in it, and generates an AST.
* Parses a DQL query, reports any errors in it, and generates an AST.
*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @version $Revision$
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
*/
*/
class
Parser
class
Parser
{
{
...
@@ -482,16 +483,16 @@ class Parser
...
@@ -482,16 +483,16 @@ class Parser
*/
*/
private
function
_validatePathExpression
(
AST\PathExpression
$pathExpression
,
$nestingLevel
=
null
,
$token
=
null
)
private
function
_validatePathExpression
(
AST\PathExpression
$pathExpression
,
$nestingLevel
=
null
,
$token
=
null
)
{
{
$ident
ificationVariable
=
$pathExpression
->
getIdentificationVariable
()
;
$ident
Variable
=
$pathExpression
->
identificationVariable
;
$nestingLevel
=
(
$nestingLevel
!==
null
)
?:
$this
->
_nestingLevel
;
$nestingLevel
=
(
$nestingLevel
!==
null
)
?:
$this
->
_nestingLevel
;
$token
=
(
$token
)
?:
$this
->
_lexer
->
lookahead
;
$token
=
(
$token
)
?:
$this
->
_lexer
->
lookahead
;
$this
->
_validateIdentificationVariable
(
$ident
ification
Variable
,
$nestingLevel
,
$token
);
$this
->
_validateIdentificationVariable
(
$identVariable
,
$nestingLevel
,
$token
);
$class
=
$this
->
_queryComponents
[
$ident
ification
Variable
][
'metadata'
];
$class
=
$this
->
_queryComponents
[
$identVariable
][
'metadata'
];
$stateField
=
$collectionField
=
null
;
$stateField
=
$collectionField
=
null
;
foreach
(
$pathExpression
->
getParts
()
as
$field
)
{
foreach
(
$pathExpression
->
parts
as
$field
)
{
// Check if it is not in a state field
// Check if it is not in a state field
if
(
$stateField
!==
null
)
{
if
(
$stateField
!==
null
)
{
$this
->
semanticalError
(
$this
->
semanticalError
(
...
@@ -535,7 +536,7 @@ class Parser
...
@@ -535,7 +536,7 @@ class Parser
}
}
// Validate if PathExpression is one of the expected types
// Validate if PathExpression is one of the expected types
$expectedType
=
$pathExpression
->
getExpectedType
()
;
$expectedType
=
$pathExpression
->
expectedType
;
if
(
!
(
$expectedType
&
$expressionType
))
{
if
(
!
(
$expectedType
&
$expressionType
))
{
// We need to recognize which was expected type(s)
// We need to recognize which was expected type(s)
...
@@ -569,7 +570,7 @@ class Parser
...
@@ -569,7 +570,7 @@ class Parser
}
}
// We need to force the type in PathExpression
// We need to force the type in PathExpression
$pathExpression
->
setType
(
$expressionType
)
;
$pathExpression
->
type
=
$expressionType
;
return
$expressionType
;
return
$expressionType
;
}
}
...
@@ -578,33 +579,33 @@ class Parser
...
@@ -578,33 +579,33 @@ class Parser
* Validates that the given <tt>IdentificationVariable</tt> is a semantically correct.
* Validates that the given <tt>IdentificationVariable</tt> is a semantically correct.
* It must exist in query components list.
* It must exist in query components list.
*
*
* @param string $idVariable
* @param string $id
ent
Variable
* @param integer $nestingLevel
* @param integer $nestingLevel
* @param array $token
* @param array $token
* @return array Query Component
* @return array Query Component
*/
*/
private
function
_validateIdentificationVariable
(
$idVariable
,
$nestingLevel
=
null
,
$token
=
null
)
private
function
_validateIdentificationVariable
(
$id
ent
Variable
,
$nestingLevel
=
null
,
$token
=
null
)
{
{
$nestingLevel
=
(
$nestingLevel
!==
null
)
?:
$this
->
_nestingLevel
;
$nestingLevel
=
(
$nestingLevel
!==
null
)
?:
$this
->
_nestingLevel
;
$token
=
(
$token
)
?:
$this
->
_lexer
->
lookahead
;
$token
=
(
$token
)
?:
$this
->
_lexer
->
lookahead
;
if
(
!
isset
(
$this
->
_queryComponents
[
$idVariable
]))
{
if
(
!
isset
(
$this
->
_queryComponents
[
$id
ent
Variable
]))
{
echo
'[Query Components: '
.
var_export
(
$this
->
_queryComponents
,
true
)
.
']'
;
echo
'[Query Components: '
.
var_export
(
$this
->
_queryComponents
,
true
)
.
']'
;
$this
->
semanticalError
(
$this
->
semanticalError
(
"Could not find '
$idVariable
' in query components"
,
$token
"Could not find '
$id
ent
Variable
' in query components"
,
$token
);
);
}
}
// Validate if identification variable nesting level is lower or equal than the current one
// Validate if identification variable nesting level is lower or equal than the current one
if
(
$this
->
_queryComponents
[
$idVariable
][
'nestingLevel'
]
>
$nestingLevel
)
{
if
(
$this
->
_queryComponents
[
$id
ent
Variable
][
'nestingLevel'
]
>
$nestingLevel
)
{
$this
->
semanticalError
(
$this
->
semanticalError
(
"Query component '
$idVariable
' is not in the same nesting level of its declaration"
,
"Query component '
$id
ent
Variable
' is not in the same nesting level of its declaration"
,
$token
$token
);
);
}
}
return
$this
->
_queryComponents
[
$idVariable
];
return
$this
->
_queryComponents
[
$id
ent
Variable
];
}
}
...
@@ -647,27 +648,24 @@ class Parser
...
@@ -647,27 +648,24 @@ class Parser
// since we do not have any IdentificationVariable yet
// since we do not have any IdentificationVariable yet
$this
->
_beginDeferredPathExpressionStack
();
$this
->
_beginDeferredPathExpressionStack
();
$selectClause
=
$this
->
SelectClause
();
$selectStatement
=
new
AST\SelectStatement
(
$this
->
SelectClause
(),
$this
->
FromClause
());
$fromClause
=
$this
->
FromClause
();
// Activate semantical checks after this point. Process all deferred checks in pipeline
// Activate semantical checks after this point. Process all deferred checks in pipeline
$this
->
_processDeferredPathExpressionStack
();
$this
->
_processDeferredPathExpressionStack
();
$whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
$
selectStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
;
?
$this
->
WhereClause
()
:
null
;
$groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
$
selectStatement
->
groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
?
$this
->
GroupByClause
()
:
null
;
?
$this
->
GroupByClause
()
:
null
;
$havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
$
selectStatement
->
havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
?
$this
->
HavingClause
()
:
null
;
?
$this
->
HavingClause
()
:
null
;
$orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
$
selectStatement
->
orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
?
$this
->
OrderByClause
()
:
null
;
?
$this
->
OrderByClause
()
:
null
;
return
new
AST\SelectStatement
(
return
$selectStatement
;
$selectClause
,
$fromClause
,
$whereClause
,
$groupByClause
,
$havingClause
,
$orderByClause
);
}
}
/**
/**
...
@@ -678,9 +676,8 @@ class Parser
...
@@ -678,9 +676,8 @@ class Parser
public
function
UpdateStatement
()
public
function
UpdateStatement
()
{
{
$updateStatement
=
new
AST\UpdateStatement
(
$this
->
UpdateClause
());
$updateStatement
=
new
AST\UpdateStatement
(
$this
->
UpdateClause
());
$updateStatement
->
setWhereClause
(
$updateStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
?
$this
->
WhereClause
()
:
null
;
);
return
$updateStatement
;
return
$updateStatement
;
}
}
...
@@ -693,9 +690,8 @@ class Parser
...
@@ -693,9 +690,8 @@ class Parser
public
function
DeleteStatement
()
public
function
DeleteStatement
()
{
{
$deleteStatement
=
new
AST\DeleteStatement
(
$this
->
DeleteClause
());
$deleteStatement
=
new
AST\DeleteStatement
(
$this
->
DeleteClause
());
$deleteStatement
->
setWhereClause
(
$deleteStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
?
$this
->
WhereClause
()
:
null
;
);
return
$deleteStatement
;
return
$deleteStatement
;
}
}
...
@@ -758,22 +754,22 @@ class Parser
...
@@ -758,22 +754,22 @@ class Parser
public
function
JoinAssociationPathExpression
()
public
function
JoinAssociationPathExpression
()
{
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
$this
->
match
(
'.'
);
$this
->
match
(
'.'
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
$field
=
$this
->
_lexer
->
token
[
'value'
];
$field
=
$this
->
_lexer
->
token
[
'value'
];
// Validating IdentificationVariable (it was already defined previously)
// Validating IdentificationVariable (it was already defined previously)
$this
->
_validateIdentificationVariable
(
$ident
ification
Variable
,
null
,
$token
);
$this
->
_validateIdentificationVariable
(
$identVariable
,
null
,
$token
);
// Validating association field (*-to-one or *-to-many)
// Validating association field (*-to-one or *-to-many)
$class
=
$this
->
_queryComponents
[
$ident
ification
Variable
][
'metadata'
];
$class
=
$this
->
_queryComponents
[
$identVariable
][
'metadata'
];
if
(
!
isset
(
$class
->
associationMappings
[
$field
]))
{
if
(
!
isset
(
$class
->
associationMappings
[
$field
]))
{
$this
->
semanticalError
(
'Class '
.
$class
->
name
.
' has no field named '
.
$field
);
$this
->
semanticalError
(
'Class '
.
$class
->
name
.
' has no field named '
.
$field
);
}
}
return
new
AST\JoinAssociationPathExpression
(
$ident
ification
Variable
,
$field
);
return
new
AST\JoinAssociationPathExpression
(
$identVariable
,
$field
);
}
}
/**
/**
...
@@ -788,7 +784,7 @@ class Parser
...
@@ -788,7 +784,7 @@ class Parser
public
function
PathExpression
(
$expectedType
)
public
function
PathExpression
(
$expectedType
)
{
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
$parts
=
array
();
$parts
=
array
();
do
{
do
{
...
@@ -799,7 +795,7 @@ class Parser
...
@@ -799,7 +795,7 @@ class Parser
}
while
(
$this
->
_lexer
->
isNextToken
(
'.'
));
}
while
(
$this
->
_lexer
->
isNextToken
(
'.'
));
// Creating AST node
// Creating AST node
$pathExpr
=
new
AST\PathExpression
(
$expectedType
,
$ident
ification
Variable
,
$parts
);
$pathExpr
=
new
AST\PathExpression
(
$expectedType
,
$identVariable
,
$parts
);
// Defer PathExpression validation if requested to be defered
// Defer PathExpression validation if requested to be defered
if
(
!
empty
(
$this
->
_deferredPathExpressionStacks
))
{
if
(
!
empty
(
$this
->
_deferredPathExpressionStacks
))
{
...
@@ -884,7 +880,7 @@ class Parser
...
@@ -884,7 +880,7 @@ class Parser
public
function
SimpleStateFieldPathExpression
()
public
function
SimpleStateFieldPathExpression
()
{
{
$pathExpression
=
$this
->
PathExpression
(
AST\PathExpression
::
TYPE_STATE_FIELD
);
$pathExpression
=
$this
->
PathExpression
(
AST\PathExpression
::
TYPE_STATE_FIELD
);
$parts
=
$pathExpression
->
getParts
()
;
$parts
=
$pathExpression
->
parts
;
if
(
count
(
$parts
)
>
1
)
{
if
(
count
(
$parts
)
>
1
)
{
$this
->
semanticalError
(
$this
->
semanticalError
(
...
@@ -932,18 +928,15 @@ class Parser
...
@@ -932,18 +928,15 @@ class Parser
*/
*/
public
function
SimpleSelectClause
()
public
function
SimpleSelectClause
()
{
{
$
d
istinct
=
false
;
$
isD
istinct
=
false
;
$this
->
match
(
Lexer
::
T_SELECT
);
$this
->
match
(
Lexer
::
T_SELECT
);
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DISTINCT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DISTINCT
))
{
$this
->
match
(
Lexer
::
T_DISTINCT
);
$this
->
match
(
Lexer
::
T_DISTINCT
);
$
d
istinct
=
true
;
$
isD
istinct
=
true
;
}
}
$simpleSelectClause
=
new
AST\SimpleSelectClause
(
$this
->
SimpleSelectExpression
());
return
new
AST\SimpleSelectClause
(
$this
->
SimpleSelectExpression
(),
$isDistinct
);
$simpleSelectClause
->
setDistinct
(
$distinct
);
return
$simpleSelectClause
;
}
}
/**
/**
...
@@ -992,7 +985,7 @@ class Parser
...
@@ -992,7 +985,7 @@ class Parser
}
}
$updateClause
=
new
AST\UpdateClause
(
$abstractSchemaName
,
$updateItems
);
$updateClause
=
new
AST\UpdateClause
(
$abstractSchemaName
,
$updateItems
);
$updateClause
->
setAliasIdentificationVariable
(
$aliasIdentificationVariable
)
;
$updateClause
->
aliasIdentificationVariable
=
$aliasIdentificationVariable
;
return
$updateClause
;
return
$updateClause
;
}
}
...
@@ -1022,11 +1015,11 @@ class Parser
...
@@ -1022,11 +1015,11 @@ class Parser
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
}
else
{
}
else
{
$aliasIdentificationVariable
=
$deleteClause
->
getAbstractSchemaName
()
;
$aliasIdentificationVariable
=
$deleteClause
->
abstractSchemaName
;
}
}
$deleteClause
->
setAliasIdentificationVariable
(
$aliasIdentificationVariable
)
;
$deleteClause
->
aliasIdentificationVariable
=
$aliasIdentificationVariable
;
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
getAbstractSchemaName
()
);
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
abstractSchemaName
);
// Building queryComponent
// Building queryComponent
$queryComponent
=
array
(
$queryComponent
=
array
(
...
@@ -1156,24 +1149,22 @@ class Parser
...
@@ -1156,24 +1149,22 @@ class Parser
$this
->
_nestingLevel
++
;
$this
->
_nestingLevel
++
;
$this
->
_beginDeferredPathExpressionStack
();
$this
->
_beginDeferredPathExpressionStack
();
$subselect
=
new
AST\Subselect
(
$this
->
SimpleSelectClause
(),
$this
->
SubselectFromClause
());
$subselect
=
new
AST\Subselect
(
$this
->
SimpleSelectClause
(),
$this
->
SubselectFromClause
());
$this
->
_processDeferredPathExpressionStack
();
$this
->
_processDeferredPathExpressionStack
();
$subselect
->
setWhereClause
(
$subselect
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
?
$this
->
WhereClause
()
:
null
;
);
$subselect
->
setGroupByClause
(
$subselect
->
groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
?
$this
->
GroupByClause
()
:
null
?
$this
->
GroupByClause
()
:
null
;
);
$subselect
->
setHavingClause
(
$subselect
->
havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
?
$this
->
HavingClause
()
:
null
?
$this
->
HavingClause
()
:
null
;
);
$subselect
->
setOrderByClause
(
$subselect
->
orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
?
$this
->
OrderByClause
()
:
null
?
$this
->
OrderByClause
()
:
null
;
);
// Decrease query nesting level
// Decrease query nesting level
$this
->
_nestingLevel
--
;
$this
->
_nestingLevel
--
;
...
@@ -1190,10 +1181,10 @@ class Parser
...
@@ -1190,10 +1181,10 @@ class Parser
public
function
UpdateItem
()
public
function
UpdateItem
()
{
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
// Validate if IdentificationVariable is defined
// Validate if IdentificationVariable is defined
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$ident
ification
Variable
,
null
,
$token
);
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$identVariable
,
null
,
$token
);
$this
->
match
(
'.'
);
$this
->
match
(
'.'
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
...
@@ -1213,7 +1204,7 @@ class Parser
...
@@ -1213,7 +1204,7 @@ class Parser
$newValue
=
$this
->
NewValue
();
$newValue
=
$this
->
NewValue
();
$updateItem
=
new
AST\UpdateItem
(
$field
,
$newValue
);
$updateItem
=
new
AST\UpdateItem
(
$field
,
$newValue
);
$updateItem
->
setIdentificationVariable
(
$identificationVariable
)
;
$updateItem
->
identificationVariable
=
$identVariable
;
return
$updateItem
;
return
$updateItem
;
}
}
...
@@ -1230,12 +1221,12 @@ class Parser
...
@@ -1230,12 +1221,12 @@ class Parser
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
// Validate if IdentificationVariable is defined
// Validate if IdentificationVariable is defined
$this
->
_validateIdentificationVariable
(
$ident
ification
Variable
,
null
,
$token
);
$this
->
_validateIdentificationVariable
(
$identVariable
,
null
,
$token
);
return
$ident
ification
Variable
;
return
$identVariable
;
}
}
return
$this
->
SingleValuedPathExpression
();
return
$this
->
SingleValuedPathExpression
();
...
@@ -1251,15 +1242,17 @@ class Parser
...
@@ -1251,15 +1242,17 @@ class Parser
*/
*/
public
function
OrderByItem
()
public
function
OrderByItem
()
{
{
$type
=
'ASC'
;
// We need to check if we are in a ResultVariable or StateFieldPathExpression
// We need to check if we are in a ResultVariable or StateFieldPathExpression
$glimpse
=
$this
->
_lexer
->
glimpse
();
$glimpse
=
$this
->
_lexer
->
glimpse
();
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$
expr
=
$this
->
ResultVariable
();
$
resultVariable
=
$this
->
ResultVariable
();
// Check if ResultVariable is defined in query components
// Check if ResultVariable is defined in query components
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$
expr
,
null
,
$token
);
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$
resultVariable
,
null
,
$token
);
// Outer defininition used in inner subselect is not enough.
// Outer defininition used in inner subselect is not enough.
// ResultVariable exists in queryComponents, check nesting level
// ResultVariable exists in queryComponents, check nesting level
...
@@ -1276,17 +1269,12 @@ class Parser
...
@@ -1276,17 +1269,12 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ASC
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ASC
))
{
$this
->
match
(
Lexer
::
T_ASC
);
$this
->
match
(
Lexer
::
T_ASC
);
$item
->
setAsc
(
true
);
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DESC
))
{
return
$item
;
}
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DESC
))
{
$this
->
match
(
Lexer
::
T_DESC
);
$this
->
match
(
Lexer
::
T_DESC
);
$item
->
setDesc
(
true
);
$type
=
'DESC'
;
return
$item
;
}
}
$item
->
setAsc
(
true
)
;
$item
->
type
=
$type
;
return
$item
;
return
$item
;
}
}
...
@@ -1350,10 +1338,10 @@ class Parser
...
@@ -1350,10 +1338,10 @@ class Parser
$peek
=
$this
->
_lexer
->
glimpse
();
$peek
=
$this
->
_lexer
->
glimpse
();
if
(
$peek
[
'value'
]
==
'.'
)
{
if
(
$peek
[
'value'
]
==
'.'
)
{
$subselectIdVarDecl
=
new
AST\SubselectIdentificationVariableDeclaration
;
$subselectIdVarDecl
=
new
AST\SubselectIdentificationVariableDeclaration
()
;
$subselectIdVarDecl
->
setAssociationPathExpression
(
$this
->
AssociationPathExpression
()
);
$subselectIdVarDecl
->
associationPathExpression
=
$this
->
AssociationPathExpression
(
);
$this
->
match
(
Lexer
::
T_AS
);
$this
->
match
(
Lexer
::
T_AS
);
$subselectIdVarDecl
->
setAliasIdentificationVariable
(
$this
->
AliasIdentificationVariable
()
);
$subselectIdVarDecl
->
aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
(
);
return
$subselectIdVarDecl
;
return
$subselectIdVarDecl
;
}
}
...
@@ -1445,8 +1433,8 @@ class Parser
...
@@ -1445,8 +1433,8 @@ class Parser
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
// Verify that the association exists.
// Verify that the association exists.
$parentClass
=
$this
->
_queryComponents
[
$joinPathExpression
->
getIdentificationVariable
()
][
'metadata'
];
$parentClass
=
$this
->
_queryComponents
[
$joinPathExpression
->
identificationVariable
][
'metadata'
];
$assocField
=
$joinPathExpression
->
getAssociationField
()
;
$assocField
=
$joinPathExpression
->
associationField
;
if
(
!
$parentClass
->
hasAssociation
(
$assocField
))
{
if
(
!
$parentClass
->
hasAssociation
(
$assocField
))
{
$this
->
semanticalError
(
$this
->
semanticalError
(
...
@@ -1459,7 +1447,7 @@ class Parser
...
@@ -1459,7 +1447,7 @@ class Parser
// Building queryComponent
// Building queryComponent
$joinQueryComponent
=
array
(
$joinQueryComponent
=
array
(
'metadata'
=>
$this
->
_em
->
getClassMetadata
(
$targetClassName
),
'metadata'
=>
$this
->
_em
->
getClassMetadata
(
$targetClassName
),
'parent'
=>
$joinPathExpression
->
getIdentificationVariable
()
,
'parent'
=>
$joinPathExpression
->
identificationVariable
,
'relation'
=>
$parentClass
->
getAssociationMapping
(
$assocField
),
'relation'
=>
$parentClass
->
getAssociationMapping
(
$assocField
),
'map'
=>
null
,
'map'
=>
null
,
'nestingLevel'
=>
$this
->
_nestingLevel
,
'nestingLevel'
=>
$this
->
_nestingLevel
,
...
@@ -1474,12 +1462,12 @@ class Parser
...
@@ -1474,12 +1462,12 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ON
)
||
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WITH
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ON
)
||
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WITH
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ON
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ON
))
{
$this
->
match
(
Lexer
::
T_ON
);
$this
->
match
(
Lexer
::
T_ON
);
$join
->
setWhereType
(
AST\Join
::
JOIN_WHERE_ON
)
;
$join
->
whereType
=
AST\Join
::
JOIN_WHERE_ON
;
}
else
{
}
else
{
$this
->
match
(
Lexer
::
T_WITH
);
$this
->
match
(
Lexer
::
T_WITH
);
}
}
$join
->
setConditionalExpression
(
$this
->
ConditionalExpression
()
);
$join
->
conditionalExpression
=
$this
->
ConditionalExpression
(
);
}
}
return
$join
;
return
$join
;
...
@@ -1497,8 +1485,8 @@ class Parser
...
@@ -1497,8 +1485,8 @@ class Parser
$pathExp
=
$this
->
SimpleStateFieldPathExpression
();
$pathExp
=
$this
->
SimpleStateFieldPathExpression
();
// Add the INDEX BY info to the query component
// Add the INDEX BY info to the query component
$parts
=
$pathExp
->
getParts
()
;
$parts
=
$pathExp
->
parts
;
$this
->
_queryComponents
[
$pathExp
->
getIdentificationVariable
()
][
'map'
]
=
$parts
[
0
];
$this
->
_queryComponents
[
$pathExp
->
identificationVariable
][
'map'
]
=
$parts
[
0
];
return
$pathExp
;
return
$pathExp
;
}
}
...
@@ -1593,7 +1581,7 @@ class Parser
...
@@ -1593,7 +1581,7 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_IDENTIFIER
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_IDENTIFIER
))
{
$token
=
$this
->
_lexer
->
lookahead
;
$token
=
$this
->
_lexer
->
lookahead
;
$resultVariable
=
$this
->
ResultVariable
();
$resultVariable
=
$this
->
ResultVariable
();
$expr
->
setFieldIdentificationVariable
(
$resultVariable
)
;
$expr
->
fieldIdentificationVariable
=
$resultVariable
;
// Include ResultVariable in query components.
// Include ResultVariable in query components.
$this
->
_queryComponents
[
$resultVariable
]
=
array
(
$this
->
_queryComponents
[
$resultVariable
]
=
array
(
...
@@ -1657,7 +1645,10 @@ class Parser
...
@@ -1657,7 +1645,10 @@ class Parser
$not
=
true
;
$not
=
true
;
}
}
return
new
AST\ConditionalFactor
(
$this
->
ConditionalPrimary
(),
$not
);
$condFactor
=
new
AST\ConditionalFactor
(
$this
->
ConditionalPrimary
());
$condFactor
->
not
=
$not
;
return
$condFactor
;
}
}
/**
/**
...
@@ -1691,14 +1682,14 @@ class Parser
...
@@ -1691,14 +1682,14 @@ class Parser
// Check if unmatched parenthesis is > 0, then we found a matching arithmetic operator
// Check if unmatched parenthesis is > 0, then we found a matching arithmetic operator
if
(
$numUnmatched
>
0
)
{
if
(
$numUnmatched
>
0
)
{
$condPrimary
->
s
etSimpleConditionalExpression
(
$this
->
SimpleConditionalExpression
()
);
$condPrimary
->
s
impleConditionalExpression
=
$this
->
SimpleConditionalExpression
(
);
}
else
{
}
else
{
$this
->
match
(
'('
);
$this
->
match
(
'('
);
$condPrimary
->
setConditionalExpression
(
$this
->
ConditionalExpression
()
);
$condPrimary
->
conditionalExpression
=
$this
->
ConditionalExpression
(
);
$this
->
match
(
')'
);
$this
->
match
(
')'
);
}
}
}
else
{
}
else
{
$condPrimary
->
s
etSimpleConditionalExpression
(
$this
->
SimpleConditionalExpression
()
);
$condPrimary
->
s
impleConditionalExpression
=
$this
->
SimpleConditionalExpression
(
);
}
}
return
$condPrimary
;
return
$condPrimary
;
...
@@ -1799,7 +1790,7 @@ class Parser
...
@@ -1799,7 +1790,7 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$this
->
match
(
Lexer
::
T_NOT
);
$emptyColletionCompExpr
->
setNot
(
true
)
;
$emptyColletionCompExpr
->
not
=
true
;
}
}
$this
->
match
(
Lexer
::
T_EMPTY
);
$this
->
match
(
Lexer
::
T_EMPTY
);
...
@@ -1817,12 +1808,12 @@ class Parser
...
@@ -1817,12 +1808,12 @@ class Parser
*/
*/
public
function
CollectionMemberExpression
()
public
function
CollectionMemberExpression
()
{
{
$
isN
ot
=
false
;
$
n
ot
=
false
;
$entityExpr
=
$this
->
EntityExpression
();
$entityExpr
=
$this
->
EntityExpression
();
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$
isN
ot
=
true
;
$
n
ot
=
true
;
$this
->
match
(
Lexer
::
T_NOT
);
$this
->
match
(
Lexer
::
T_NOT
);
}
}
...
@@ -1832,9 +1823,12 @@ class Parser
...
@@ -1832,9 +1823,12 @@ class Parser
$this
->
match
(
Lexer
::
T_OF
);
$this
->
match
(
Lexer
::
T_OF
);
}
}
return
new
AST\CollectionMemberExpression
(
$collMemberExpr
=
new
AST\CollectionMemberExpression
(
$entityExpr
,
$this
->
CollectionValuedPathExpression
()
,
$isNot
$entityExpr
,
$this
->
CollectionValuedPathExpression
()
);
);
$collMemberExpr
->
not
=
$not
;
return
$collMemberExpr
;
}
}
...
@@ -1967,17 +1961,17 @@ class Parser
...
@@ -1967,17 +1961,17 @@ class Parser
*/
*/
public
function
ArithmeticFactor
()
public
function
ArithmeticFactor
()
{
{
$
pSign
=
$nSign
=
false
;
$
sign
=
null
;
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'+'
)
{
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'+'
)
{
$this
->
match
(
'+'
);
$this
->
match
(
'+'
);
$
pS
ign
=
true
;
$
s
ign
=
true
;
}
else
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'-'
)
{
}
else
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'-'
)
{
$this
->
match
(
'-'
);
$this
->
match
(
'-'
);
$
nSign
=
tru
e
;
$
sign
=
fals
e
;
}
}
return
new
AST\ArithmeticFactor
(
$this
->
ArithmeticPrimary
(),
$
pSign
,
$nS
ign
);
return
new
AST\ArithmeticFactor
(
$this
->
ArithmeticPrimary
(),
$
s
ign
);
}
}
/**
/**
...
@@ -2171,29 +2165,26 @@ class Parser
...
@@ -2171,29 +2165,26 @@ class Parser
*/
*/
public
function
QuantifiedExpression
()
public
function
QuantifiedExpression
()
{
{
$
all
=
$any
=
$some
=
false
;
$
type
=
''
;
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ALL
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ALL
))
{
$this
->
match
(
Lexer
::
T_ALL
);
$this
->
match
(
Lexer
::
T_ALL
);
$
all
=
true
;
$
type
=
'ALL'
;
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ANY
))
{
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ANY
))
{
$this
->
match
(
Lexer
::
T_ANY
);
$this
->
match
(
Lexer
::
T_ANY
);
$any
=
true
;
$type
=
'ANY'
;
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SOME
))
{
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SOME
))
{
$this
->
match
(
Lexer
::
T_SOME
);
$this
->
match
(
Lexer
::
T_SOME
);
$some
=
true
;
$type
=
'SOME'
;
}
else
{
}
else
{
$this
->
syntaxError
(
'ALL, ANY or SOME'
);
$this
->
syntaxError
(
'ALL, ANY or SOME'
);
}
}
$this
->
match
(
'('
);
$this
->
match
(
'('
);
$qExpr
=
new
AST\QuantifiedExpression
(
$this
->
Subselect
());
$qExpr
=
new
AST\QuantifiedExpression
(
$this
->
Subselect
());
$qExpr
->
type
=
$type
;
$this
->
match
(
')'
);
$this
->
match
(
')'
);
$qExpr
->
setAll
(
$all
);
$qExpr
->
setAny
(
$any
);
$qExpr
->
setSome
(
$some
);
return
$qExpr
;
return
$qExpr
;
}
}
...
@@ -2218,7 +2209,7 @@ class Parser
...
@@ -2218,7 +2209,7 @@ class Parser
$arithExpr3
=
$this
->
ArithmeticExpression
();
$arithExpr3
=
$this
->
ArithmeticExpression
();
$betweenExpr
=
new
AST\BetweenExpression
(
$arithExpr1
,
$arithExpr2
,
$arithExpr3
);
$betweenExpr
=
new
AST\BetweenExpression
(
$arithExpr1
,
$arithExpr2
,
$arithExpr3
);
$betweenExpr
->
setNot
(
$not
)
;
$betweenExpr
->
not
=
$not
;
return
$betweenExpr
;
return
$betweenExpr
;
}
}
...
@@ -2255,14 +2246,14 @@ class Parser
...
@@ -2255,14 +2246,14 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$this
->
match
(
Lexer
::
T_NOT
);
$inExpression
->
setNot
(
true
)
;
$inExpression
->
not
=
true
;
}
}
$this
->
match
(
Lexer
::
T_IN
);
$this
->
match
(
Lexer
::
T_IN
);
$this
->
match
(
'('
);
$this
->
match
(
'('
);
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SELECT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SELECT
))
{
$inExpression
->
s
etSubselect
(
$this
->
Subselect
()
);
$inExpression
->
s
ubselect
=
$this
->
Subselect
(
);
}
else
{
}
else
{
$literals
=
array
();
$literals
=
array
();
$literals
[]
=
$this
->
InParameter
();
$literals
[]
=
$this
->
InParameter
();
...
@@ -2272,7 +2263,7 @@ class Parser
...
@@ -2272,7 +2263,7 @@ class Parser
$literals
[]
=
$this
->
InParameter
();
$literals
[]
=
$this
->
InParameter
();
}
}
$inExpression
->
setLiterals
(
$literals
)
;
$inExpression
->
literals
=
$literals
;
}
}
$this
->
match
(
')'
);
$this
->
match
(
')'
);
...
@@ -2288,11 +2279,11 @@ class Parser
...
@@ -2288,11 +2279,11 @@ class Parser
public
function
LikeExpression
()
public
function
LikeExpression
()
{
{
$stringExpr
=
$this
->
StringExpression
();
$stringExpr
=
$this
->
StringExpression
();
$
isN
ot
=
false
;
$
n
ot
=
false
;
if
(
$this
->
_lexer
->
lookahead
[
'type'
]
===
Lexer
::
T_NOT
)
{
if
(
$this
->
_lexer
->
lookahead
[
'type'
]
===
Lexer
::
T_NOT
)
{
$this
->
match
(
Lexer
::
T_NOT
);
$this
->
match
(
Lexer
::
T_NOT
);
$
isN
ot
=
true
;
$
n
ot
=
true
;
}
}
$this
->
match
(
Lexer
::
T_LIKE
);
$this
->
match
(
Lexer
::
T_LIKE
);
...
@@ -2313,7 +2304,10 @@ class Parser
...
@@ -2313,7 +2304,10 @@ class Parser
$escapeChar
=
$this
->
_lexer
->
token
[
'value'
];
$escapeChar
=
$this
->
_lexer
->
token
[
'value'
];
}
}
return
new
AST\LikeExpression
(
$stringExpr
,
$stringPattern
,
$isNot
,
$escapeChar
);
$likeExpr
=
new
AST\LikeExpression
(
$stringExpr
,
$stringPattern
,
$escapeChar
);
$likeExpr
->
not
=
$not
;
return
$likeExpr
;
}
}
/**
/**
...
@@ -2335,7 +2329,7 @@ class Parser
...
@@ -2335,7 +2329,7 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$this
->
match
(
Lexer
::
T_NOT
);
$nullCompExpr
->
setNot
(
true
)
;
$nullCompExpr
->
not
=
true
;
}
}
$this
->
match
(
Lexer
::
T_NULL
);
$this
->
match
(
Lexer
::
T_NULL
);
...
@@ -2360,8 +2354,8 @@ class Parser
...
@@ -2360,8 +2354,8 @@ class Parser
$this
->
match
(
Lexer
::
T_EXISTS
);
$this
->
match
(
Lexer
::
T_EXISTS
);
$this
->
match
(
'('
);
$this
->
match
(
'('
);
$existsExpression
=
new
AST\ExistsExpression
(
$this
->
Subselect
());
$existsExpression
=
new
AST\ExistsExpression
(
$this
->
Subselect
());
$existsExpression
->
not
=
$not
;
$this
->
match
(
')'
);
$this
->
match
(
')'
);
$existsExpression
->
setNot
(
$not
);
return
$existsExpression
;
return
$existsExpression
;
}
}
...
...
lib/Doctrine/ORM/Query/SqlWalker.php
View file @
33fc28ff
...
@@ -122,11 +122,144 @@ class SqlWalker implements TreeWalker
...
@@ -122,11 +122,144 @@ class SqlWalker implements TreeWalker
return
$this
->
_em
;
return
$this
->
_em
;
}
}
/**
* Gets the Query Component related to the given DQL alias.
*
* @param string $dqlAlias DQL alias
* @return array
*/
public
function
getQueryComponent
(
$dqlAlias
)
public
function
getQueryComponent
(
$dqlAlias
)
{
{
return
$this
->
_queryComponents
[
$dqlAlias
];
return
$this
->
_queryComponents
[
$dqlAlias
];
}
}
/**
* Gets an executor that can be used to execute the result of this walker.
*
* @return AbstractExecutor
*/
public
function
getExecutor
(
$AST
)
{
$isDeleteStatement
=
$AST
instanceof
AST\DeleteStatement
;
$isUpdateStatement
=
$AST
instanceof
AST\UpdateStatement
;
if
(
$isDeleteStatement
)
{
$primaryClass
=
$this
->
_em
->
getClassMetadata
(
$AST
->
deleteClause
->
abstractSchemaName
);
if
(
$primaryClass
->
isInheritanceTypeJoined
())
{
return
new
Exec\MultiTableDeleteExecutor
(
$AST
,
$this
);
}
else
{
return
new
Exec\SingleTableDeleteUpdateExecutor
(
$AST
,
$this
);
}
}
else
if
(
$isUpdateStatement
)
{
$primaryClass
=
$this
->
_em
->
getClassMetadata
(
$AST
->
updateClause
->
abstractSchemaName
);
if
(
$primaryClass
->
isInheritanceTypeJoined
())
{
return
new
Exec\MultiTableUpdateExecutor
(
$AST
,
$this
);
}
else
{
return
new
Exec\SingleTableDeleteUpdateExecutor
(
$AST
,
$this
);
}
}
else
{
return
new
Exec\SingleSelectExecutor
(
$AST
,
$this
);
}
}
/**
* Generates a unique, short SQL table alias.
*
* @param string $dqlAlias The DQL alias.
* @return string Generated table alias.
*/
public
function
getSqlTableAlias
(
$tableName
,
$dqlAlias
=
''
)
{
$tableName
.=
$dqlAlias
;
if
(
!
isset
(
$this
->
_dqlToSqlAliasMap
[
$tableName
]))
{
$this
->
_dqlToSqlAliasMap
[
$tableName
]
=
strtolower
(
substr
(
$tableName
,
0
,
1
))
.
$this
->
_tableAliasCounter
++
.
'_'
;
}
return
$this
->
_dqlToSqlAliasMap
[
$tableName
];
}
/**
* Forces the SqlWalker to use a specific alias for a table name, rather than
* generating an alias on its own.
*
* @param string $tableName
* @param string $alias
*/
public
function
setSqlTableAlias
(
$tableName
,
$alias
)
{
$this
->
_dqlToSqlAliasMap
[
$tableName
]
=
$alias
;
}
/**
* Gets an SQL column alias for a column name.
*
* @param string $columnName
* @return string
*/
public
function
getSqlColumnAlias
(
$columnName
)
{
return
trim
(
$columnName
,
'`'
)
.
$this
->
_aliasCounter
++
;
}
/**
* Generates the SQL JOINs that are necessary for Class Table Inheritance
* for the given class.
*
* @param ClassMetadata $class The class for which to generate the joins.
* @param string $dqlAlias The DQL alias of the class.
* @return string The SQL.
*/
private
function
_generateClassTableInheritanceJoins
(
$class
,
$dqlAlias
)
{
$sql
=
''
;
$baseTableAlias
=
$this
->
getSqlTableAlias
(
$class
->
primaryTable
[
'name'
],
$dqlAlias
);
$idColumns
=
$class
->
getIdentifierColumnNames
();
// INNER JOIN parent class tables
foreach
(
$class
->
parentClasses
as
$parentClassName
)
{
$parentClass
=
$this
->
_em
->
getClassMetadata
(
$parentClassName
);
$tableAlias
=
$this
->
getSqlTableAlias
(
$parentClass
->
primaryTable
[
'name'
],
$dqlAlias
);
$sql
.=
' INNER JOIN '
.
$this
->
_conn
->
quoteIdentifier
(
$parentClass
->
primaryTable
[
'name'
])
.
' '
.
$tableAlias
.
' ON '
;
$first
=
true
;
foreach
(
$idColumns
as
$idColumn
)
{
if
(
$first
)
$first
=
false
;
else
$sql
.=
' AND '
;
$sql
.=
$baseTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
)
.
' = '
.
$tableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
);
}
}
// LEFT JOIN subclass tables
foreach
(
$class
->
subClasses
as
$subClassName
)
{
$subClass
=
$this
->
_em
->
getClassMetadata
(
$subClassName
);
$tableAlias
=
$this
->
getSqlTableAlias
(
$subClass
->
primaryTable
[
'name'
],
$dqlAlias
);
$sql
.=
' LEFT JOIN '
.
$subClass
->
primaryTable
[
'name'
]
.
' '
.
$tableAlias
.
' ON '
;
$first
=
true
;
foreach
(
$idColumns
as
$idColumn
)
{
if
(
$first
)
$first
=
false
;
else
$sql
.=
' AND '
;
$sql
.=
$baseTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
)
.
' = '
.
$tableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
);
}
}
return
$sql
;
}
/**
/**
* Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
* Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
*
*
...
@@ -134,18 +267,18 @@ class SqlWalker implements TreeWalker
...
@@ -134,18 +267,18 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkSelectStatement
(
AST\SelectStatement
$AST
)
public
function
walkSelectStatement
(
AST\SelectStatement
$AST
)
{
{
$sql
=
$this
->
walkSelectClause
(
$AST
->
getSelectClause
()
);
$sql
=
$this
->
walkSelectClause
(
$AST
->
selectClause
);
$sql
.=
$this
->
walkFromClause
(
$AST
->
getFromClause
()
);
$sql
.=
$this
->
walkFromClause
(
$AST
->
fromClause
);
if
(
$whereClause
=
$AST
->
getWhereClause
()
)
{
if
(
$whereClause
=
$AST
->
whereClause
)
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
$sql
.=
' WHERE '
.
$discSql
;
}
}
$sql
.=
$AST
->
g
etGroupByClause
()
?
$this
->
walkGroupByClause
(
$AST
->
getGroupByClause
()
)
:
''
;
$sql
.=
$AST
->
g
roupByClause
?
$this
->
walkGroupByClause
(
$AST
->
groupByClause
)
:
''
;
$sql
.=
$AST
->
getHavingClause
()
?
$this
->
walkHavingClause
(
$AST
->
getHavingClause
()
)
:
''
;
$sql
.=
$AST
->
havingClause
?
$this
->
walkHavingClause
(
$AST
->
havingClause
)
:
''
;
$sql
.=
$AST
->
getOrderByClause
()
?
$this
->
walkOrderByClause
(
$AST
->
getOrderByClause
()
)
:
''
;
$sql
.=
$AST
->
orderByClause
?
$this
->
walkOrderByClause
(
$AST
->
orderByClause
)
:
''
;
$q
=
$this
->
getQuery
();
$q
=
$this
->
getQuery
();
$sql
=
$this
->
getConnection
()
->
getDatabasePlatform
()
->
modifyLimitQuery
(
$sql
=
$this
->
getConnection
()
->
getDatabasePlatform
()
->
modifyLimitQuery
(
...
@@ -155,6 +288,66 @@ class SqlWalker implements TreeWalker
...
@@ -155,6 +288,66 @@ class SqlWalker implements TreeWalker
return
$sql
;
return
$sql
;
}
}
/**
* Walks down an UpdateStatement AST node, thereby generating the appropriate SQL.
*
* @param UpdateStatement
* @return string The SQL.
*/
public
function
walkUpdateStatement
(
AST\UpdateStatement
$AST
)
{
$this
->
_useSqlTableAliases
=
false
;
$sql
=
$this
->
walkUpdateClause
(
$AST
->
updateClause
);
if
(
$whereClause
=
$AST
->
whereClause
)
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
}
return
$sql
;
}
/**
* Walks down a DeleteStatement AST node, thereby generating the appropriate SQL.
*
* @param DeleteStatement
* @return string The SQL.
*/
public
function
walkDeleteStatement
(
AST\DeleteStatement
$AST
)
{
$this
->
_useSqlTableAliases
=
false
;
$sql
=
$this
->
walkDeleteClause
(
$AST
->
deleteClause
);
if
(
$whereClause
=
$AST
->
whereClause
)
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
}
return
$sql
;
}
/**
* Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL.
*
* @param string
* @return string The SQL.
*/
public
function
walkIdentificationVariable
(
$identVariable
)
{
$qComp
=
$this
->
_queryComponents
[
$identVariable
];
$class
=
$qComp
[
'metadata'
];
if
(
!
isset
(
$this
->
_selectedClasses
[
$identVariable
]))
{
$this
->
_selectedClasses
[
$identVariable
]
=
$class
;
}
return
$this
->
_dqlToSqlAliasMap
[
$class
->
getTableName
()];
}
/**
/**
* Walks down a SelectClause AST node, thereby generating the appropriate SQL.
* Walks down a SelectClause AST node, thereby generating the appropriate SQL.
*
*
...
@@ -162,8 +355,8 @@ class SqlWalker implements TreeWalker
...
@@ -162,8 +355,8 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkSelectClause
(
$selectClause
)
public
function
walkSelectClause
(
$selectClause
)
{
{
$sql
=
'SELECT '
.
((
$selectClause
->
isDistinct
()
)
?
'DISTINCT '
:
''
)
.
implode
(
$sql
=
'SELECT '
.
((
$selectClause
->
isDistinct
)
?
'DISTINCT '
:
''
)
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkSelectExpression'
),
$selectClause
->
getSelectExpressions
()
)
', '
,
array_map
(
array
(
$this
,
'walkSelectExpression'
),
$selectClause
->
selectExpressions
)
);
);
foreach
(
$this
->
_selectedClasses
as
$dqlAlias
=>
$class
)
{
foreach
(
$this
->
_selectedClasses
as
$dqlAlias
=>
$class
)
{
...
@@ -201,13 +394,13 @@ class SqlWalker implements TreeWalker
...
@@ -201,13 +394,13 @@ class SqlWalker implements TreeWalker
public
function
walkFromClause
(
$fromClause
)
public
function
walkFromClause
(
$fromClause
)
{
{
$sql
=
' FROM '
;
$sql
=
' FROM '
;
$identificationVarDecls
=
$fromClause
->
getIdentificationVariableDeclarations
()
;
$identificationVarDecls
=
$fromClause
->
identificationVariableDeclarations
;
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$rangeDecl
=
$firstIdentificationVarDecl
->
getRangeVariableDeclaration
()
;
$rangeDecl
=
$firstIdentificationVarDecl
->
rangeVariableDeclaration
;
$dqlAlias
=
$rangeDecl
->
getAliasIdentificationVariable
()
;
$dqlAlias
=
$rangeDecl
->
aliasIdentificationVariable
;
$this
->
_currentRootAlias
=
$dqlAlias
;
$this
->
_currentRootAlias
=
$dqlAlias
;
$class
=
$rangeDecl
->
getClassMetadata
()
;
$class
=
$rangeDecl
->
classMetadata
;
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
())
.
' '
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
())
.
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$dqlAlias
);
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$dqlAlias
);
...
@@ -216,7 +409,7 @@ class SqlWalker implements TreeWalker
...
@@ -216,7 +409,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_generateClassTableInheritanceJoins
(
$class
,
$dqlAlias
);
$sql
.=
$this
->
_generateClassTableInheritanceJoins
(
$class
,
$dqlAlias
);
}
}
foreach
(
$firstIdentificationVarDecl
->
getJoinVariableDeclarations
()
as
$joinVarDecl
)
{
foreach
(
$firstIdentificationVarDecl
->
joinVariableDeclarations
as
$joinVarDecl
)
{
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
}
}
...
@@ -243,7 +436,7 @@ class SqlWalker implements TreeWalker
...
@@ -243,7 +436,7 @@ class SqlWalker implements TreeWalker
{
{
// OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
// OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
return
' ORDER BY '
.
implode
(
return
' ORDER BY '
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkOrderByItem'
),
$orderByClause
->
getOrderByItems
()
)
', '
,
array_map
(
array
(
$this
,
'walkOrderByItem'
),
$orderByClause
->
orderByItems
)
);
);
}
}
...
@@ -255,17 +448,14 @@ class SqlWalker implements TreeWalker
...
@@ -255,17 +448,14 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkOrderByItem
(
$orderByItem
)
public
function
walkOrderByItem
(
$orderByItem
)
{
{
$expr
=
$orderByItem
->
getExpression
()
;
$expr
=
$orderByItem
->
expression
;
$parts
=
$expr
->
getParts
()
;
$parts
=
$expr
->
parts
;
$dqlAlias
=
$expr
->
getIdentificationVariable
()
;
$dqlAlias
=
$expr
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
$sql
=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
return
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
' '
.
strtoupper
(
$orderByItem
->
type
);
.
(
$orderByItem
->
isDesc
()
?
' DESC'
:
' ASC'
);
return
$sql
;
}
}
/**
/**
...
@@ -279,7 +469,7 @@ class SqlWalker implements TreeWalker
...
@@ -279,7 +469,7 @@ class SqlWalker implements TreeWalker
$condExpr
=
$havingClause
->
getConditionalExpression
();
$condExpr
=
$havingClause
->
getConditionalExpression
();
return
' HAVING '
.
implode
(
return
' HAVING '
.
implode
(
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
getConditionalTerms
()
)
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
conditionalTerms
)
);
);
}
}
...
@@ -291,8 +481,8 @@ class SqlWalker implements TreeWalker
...
@@ -291,8 +481,8 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkJoinVariableDeclaration
(
$joinVarDecl
)
public
function
walkJoinVariableDeclaration
(
$joinVarDecl
)
{
{
$join
=
$joinVarDecl
->
getJoin
()
;
$join
=
$joinVarDecl
->
join
;
$joinType
=
$join
->
getJoinType
()
;
$joinType
=
$join
->
joinType
;
if
(
$joinType
==
AST\Join
::
JOIN_TYPE_LEFT
||
$joinType
==
AST\Join
::
JOIN_TYPE_LEFTOUTER
)
{
if
(
$joinType
==
AST\Join
::
JOIN_TYPE_LEFT
||
$joinType
==
AST\Join
::
JOIN_TYPE_LEFTOUTER
)
{
$sql
=
' LEFT JOIN '
;
$sql
=
' LEFT JOIN '
;
...
@@ -300,15 +490,15 @@ class SqlWalker implements TreeWalker
...
@@ -300,15 +490,15 @@ class SqlWalker implements TreeWalker
$sql
=
' INNER JOIN '
;
$sql
=
' INNER JOIN '
;
}
}
$joinAssocPathExpr
=
$join
->
getJoinAssociationPathExpression
()
;
$joinAssocPathExpr
=
$join
->
joinAssociationPathExpression
;
$joinedDqlAlias
=
$join
->
getAliasIdentificationVariable
()
;
$joinedDqlAlias
=
$join
->
aliasIdentificationVariable
;
$sourceQComp
=
$this
->
_queryComponents
[
$joinAssocPathExpr
->
getIdentificationVariable
()
];
$sourceQComp
=
$this
->
_queryComponents
[
$joinAssocPathExpr
->
identificationVariable
];
$targetQComp
=
$this
->
_queryComponents
[
$joinedDqlAlias
];
$targetQComp
=
$this
->
_queryComponents
[
$joinedDqlAlias
];
$targetTableName
=
$targetQComp
[
'metadata'
]
->
getTableName
();
$targetTableName
=
$targetQComp
[
'metadata'
]
->
getTableName
();
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetTableName
,
$joinedDqlAlias
);
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetTableName
,
$joinedDqlAlias
);
$sourceTableAlias
=
$this
->
getSqlTableAlias
(
$sourceTableAlias
=
$this
->
getSqlTableAlias
(
$sourceQComp
[
'metadata'
]
->
getTableName
(),
$joinAssocPathExpr
->
getIdentificationVariable
()
$sourceQComp
[
'metadata'
]
->
getTableName
(),
$joinAssocPathExpr
->
identificationVariable
);
);
// Ensure we got the owning side, since it has all mapping info
// Ensure we got the owning side, since it has all mapping info
...
@@ -322,6 +512,7 @@ class SqlWalker implements TreeWalker
...
@@ -322,6 +512,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$targetTableName
)
.
' '
.
$targetTableAlias
.
' ON '
;
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$targetTableName
)
.
' '
.
$targetTableAlias
.
' ON '
;
$joinColumns
=
$assoc
->
getSourceToTargetKeyColumns
();
$joinColumns
=
$assoc
->
getSourceToTargetKeyColumns
();
$first
=
true
;
$first
=
true
;
foreach
(
$joinColumns
as
$sourceColumn
=>
$targetColumn
)
{
foreach
(
$joinColumns
as
$sourceColumn
=>
$targetColumn
)
{
if
(
!
$first
)
{
if
(
!
$first
)
{
$sql
.=
' AND '
;
$sql
.=
' AND '
;
...
@@ -409,13 +600,14 @@ class SqlWalker implements TreeWalker
...
@@ -409,13 +600,14 @@ class SqlWalker implements TreeWalker
public
function
walkSelectExpression
(
$selectExpression
)
public
function
walkSelectExpression
(
$selectExpression
)
{
{
$sql
=
''
;
$sql
=
''
;
$expr
=
$selectExpression
->
getExpression
();
$expr
=
$selectExpression
->
expression
;
if
(
$expr
instanceof
AST\PathExpression
)
{
if
(
$expr
instanceof
AST\PathExpression
)
{
if
(
$expr
->
getType
()
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
if
(
$expr
->
type
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
$parts
=
$expr
->
getParts
()
;
$parts
=
$expr
->
parts
;
$numParts
=
count
(
$parts
);
$numParts
=
count
(
$parts
);
$dqlAlias
=
$expr
->
getIdentificationVariable
()
;
$dqlAlias
=
$expr
->
identificationVariable
;
$fieldName
=
$parts
[
$numParts
-
1
];
$fieldName
=
$parts
[
$numParts
-
1
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$class
=
$qComp
[
'metadata'
];
$class
=
$qComp
[
'metadata'
];
...
@@ -431,13 +623,15 @@ class SqlWalker implements TreeWalker
...
@@ -431,13 +623,15 @@ class SqlWalker implements TreeWalker
$this
->
_rsm
->
addFieldResult
(
$dqlAlias
,
$columnAlias
,
$fieldName
);
$this
->
_rsm
->
addFieldResult
(
$dqlAlias
,
$columnAlias
,
$fieldName
);
}
else
{
}
else
{
throw
DoctrineException
::
updateMe
(
"Encountered invalid PathExpression during SQL construction."
);
throw
DoctrineException
::
updateMe
(
"Encountered invalid PathExpression during SQL construction."
);
}
}
}
else
if
(
$expr
instanceof
AST\AggregateExpression
)
{
}
else
if
(
$expr
instanceof
AST\AggregateExpression
)
{
if
(
!
$selectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$selectExpression
->
fieldIdentificationVariable
)
{
$resultAlias
=
$this
->
_scalarResultCounter
++
;
$resultAlias
=
$this
->
_scalarResultCounter
++
;
}
else
{
}
else
{
$resultAlias
=
$selectExpression
->
getFieldIdentificationVariable
()
;
$resultAlias
=
$selectExpression
->
fieldIdentificationVariable
;
}
}
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
...
@@ -447,10 +641,10 @@ class SqlWalker implements TreeWalker
...
@@ -447,10 +641,10 @@ class SqlWalker implements TreeWalker
}
else
if
(
$expr
instanceof
AST\Subselect
)
{
}
else
if
(
$expr
instanceof
AST\Subselect
)
{
$sql
.=
$this
->
walkSubselect
(
$expr
);
$sql
.=
$this
->
walkSubselect
(
$expr
);
}
else
if
(
$expr
instanceof
AST\Functions\FunctionNode
)
{
}
else
if
(
$expr
instanceof
AST\Functions\FunctionNode
)
{
if
(
!
$selectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$selectExpression
->
fieldIdentificationVariable
)
{
$resultAlias
=
$this
->
_scalarResultCounter
++
;
$resultAlias
=
$this
->
_scalarResultCounter
++
;
}
else
{
}
else
{
$resultAlias
=
$selectExpression
->
getFieldIdentificationVariable
()
;
$resultAlias
=
$selectExpression
->
fieldIdentificationVariable
;
}
}
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
...
@@ -540,7 +734,8 @@ class SqlWalker implements TreeWalker
...
@@ -540,7 +734,8 @@ class SqlWalker implements TreeWalker
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
())
{
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
())
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$srcColumn
)
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$srcColumn
)
{
$columnAlias
=
$this
->
getSqlColumnAlias
(
$srcColumn
);
$columnAlias
=
$this
->
getSqlColumnAlias
(
$srcColumn
);
$sql
.=
', '
.
$sqlTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$srcColumn
)
$sql
.=
', '
.
$sqlTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$srcColumn
)
.
' AS '
.
$columnAlias
;
.
' AS '
.
$columnAlias
;
$this
->
_rsm
->
addMetaResult
(
$dqlAlias
,
$columnAlias
,
$srcColumn
);
$this
->
_rsm
->
addMetaResult
(
$dqlAlias
,
$columnAlias
,
$srcColumn
);
...
@@ -563,13 +758,8 @@ class SqlWalker implements TreeWalker
...
@@ -563,13 +758,8 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkQuantifiedExpression
(
$qExpr
)
public
function
walkQuantifiedExpression
(
$qExpr
)
{
{
$sql
=
''
;
return
' '
.
strtoupper
(
$qExpr
->
type
)
.
'('
.
$this
->
walkSubselect
(
$qExpr
->
getSubselect
())
.
')'
;
if
(
$qExpr
->
isAll
())
$sql
.=
' ALL'
;
else
if
(
$qExpr
->
isAny
())
$sql
.=
' ANY'
;
else
if
(
$qExpr
->
isSome
())
$sql
.=
' SOME'
;
return
$sql
.=
'('
.
$this
->
walkSubselect
(
$qExpr
->
getSubselect
())
.
')'
;
}
}
/**
/**
...
@@ -583,12 +773,12 @@ class SqlWalker implements TreeWalker
...
@@ -583,12 +773,12 @@ class SqlWalker implements TreeWalker
$useAliasesBefore
=
$this
->
_useSqlTableAliases
;
$useAliasesBefore
=
$this
->
_useSqlTableAliases
;
$this
->
_useSqlTableAliases
=
true
;
$this
->
_useSqlTableAliases
=
true
;
$sql
=
$this
->
walkSimpleSelectClause
(
$subselect
->
getSimpleSelectClause
()
);
$sql
=
$this
->
walkSimpleSelectClause
(
$subselect
->
simpleSelectClause
);
$sql
.=
$this
->
walkSubselectFromClause
(
$subselect
->
getSubselectFromClause
()
);
$sql
.=
$this
->
walkSubselectFromClause
(
$subselect
->
subselectFromClause
);
$sql
.=
$subselect
->
getWhereClause
()
?
$this
->
walkWhereClause
(
$subselect
->
getWhereClause
()
)
:
''
;
$sql
.=
$subselect
->
whereClause
?
$this
->
walkWhereClause
(
$subselect
->
whereClause
)
:
''
;
$sql
.=
$subselect
->
g
etGroupByClause
()
?
$this
->
walkGroupByClause
(
$subselect
->
getGroupByClause
()
)
:
''
;
$sql
.=
$subselect
->
g
roupByClause
?
$this
->
walkGroupByClause
(
$subselect
->
groupByClause
)
:
''
;
$sql
.=
$subselect
->
getHavingClause
()
?
$this
->
walkHavingClause
(
$subselect
->
getHavingClause
()
)
:
''
;
$sql
.=
$subselect
->
havingClause
?
$this
->
walkHavingClause
(
$subselect
->
havingClause
)
:
''
;
$sql
.=
$subselect
->
getOrderByClause
()
?
$this
->
walkOrderByClause
(
$subselect
->
getOrderByClause
()
)
:
''
;
$sql
.=
$subselect
->
orderByClause
?
$this
->
walkOrderByClause
(
$subselect
->
orderByClause
)
:
''
;
$this
->
_useSqlTableAliases
=
$useAliasesBefore
;
$this
->
_useSqlTableAliases
=
$useAliasesBefore
;
...
@@ -603,15 +793,15 @@ class SqlWalker implements TreeWalker
...
@@ -603,15 +793,15 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkSubselectFromClause
(
$subselectFromClause
)
public
function
walkSubselectFromClause
(
$subselectFromClause
)
{
{
$sql
=
' FROM '
;
$identificationVarDecls
=
$subselectFromClause
->
identificationVariableDeclarations
;
$identificationVarDecls
=
$subselectFromClause
->
getSubselectIdentificationVariableDeclarations
();
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$rangeDecl
=
$firstIdentificationVarDecl
->
getRangeVariableDeclaration
();
$rangeDecl
=
$firstIdentificationVarDecl
->
rangeVariableDeclaration
;
$tblName
=
$rangeDecl
->
classMetadata
->
getTableName
();
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$rangeDecl
->
getClassMetadata
()
->
getTableName
()
)
.
' '
$sql
=
' FROM '
.
$this
->
_conn
->
quoteIdentifier
(
$tblName
)
.
' '
.
$this
->
getSqlTableAlias
(
$rangeDecl
->
getClassMetadata
()
->
getTableName
(),
$rangeDecl
->
getAliasIdentificationVariable
()
);
.
$this
->
getSqlTableAlias
(
$tblName
,
$rangeDecl
->
aliasIdentificationVariable
);
foreach
(
$firstIdentificationVarDecl
->
getJoinVariableDeclarations
()
as
$joinVarDecl
)
{
foreach
(
$firstIdentificationVarDecl
->
joinVariableDeclarations
as
$joinVarDecl
)
{
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
}
}
...
@@ -626,15 +816,8 @@ class SqlWalker implements TreeWalker
...
@@ -626,15 +816,8 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkSimpleSelectClause
(
$simpleSelectClause
)
public
function
walkSimpleSelectClause
(
$simpleSelectClause
)
{
{
$sql
=
'SELECT'
;
return
'SELECT'
.
(
$simpleSelectClause
->
isDistinct
?
' DISTINCT'
:
''
)
.
$this
->
walkSimpleSelectExpression
(
$simpleSelectClause
->
simpleSelectExpression
);
if
(
$simpleSelectClause
->
isDistinct
())
{
$sql
.=
' DISTINCT'
;
}
$sql
.=
$this
->
walkSimpleSelectExpression
(
$simpleSelectClause
->
getSimpleSelectExpression
());
return
$sql
;
}
}
/**
/**
...
@@ -646,16 +829,16 @@ class SqlWalker implements TreeWalker
...
@@ -646,16 +829,16 @@ class SqlWalker implements TreeWalker
public
function
walkSimpleSelectExpression
(
$simpleSelectExpression
)
public
function
walkSimpleSelectExpression
(
$simpleSelectExpression
)
{
{
$sql
=
''
;
$sql
=
''
;
$expr
=
$simpleSelectExpression
->
getExpression
()
;
$expr
=
$simpleSelectExpression
->
expression
;
if
(
$expr
instanceof
AST\PathExpression
)
{
if
(
$expr
instanceof
AST\PathExpression
)
{
$sql
.=
' '
.
$this
->
walkPathExpression
(
$expr
);
$sql
.=
' '
.
$this
->
walkPathExpression
(
$expr
);
//...
//...
}
else
if
(
$expr
instanceof
AST\AggregateExpression
)
{
}
else
if
(
$expr
instanceof
AST\AggregateExpression
)
{
if
(
!
$simpleSelectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$simpleSelectExpression
->
fieldIdentificationVariable
)
{
$alias
=
$this
->
_scalarAliasCounter
++
;
$alias
=
$this
->
_scalarAliasCounter
++
;
}
else
{
}
else
{
$alias
=
$simpleSelectExpression
->
getFieldIdentificationVariable
()
;
$alias
=
$simpleSelectExpression
->
fieldIdentificationVariable
;
}
}
$sql
.=
$this
->
walkAggregateExpression
(
$expr
)
.
' AS dctrn__'
.
$alias
;
$sql
.=
$this
->
walkAggregateExpression
(
$expr
)
.
' AS dctrn__'
.
$alias
;
...
@@ -664,8 +847,8 @@ class SqlWalker implements TreeWalker
...
@@ -664,8 +847,8 @@ class SqlWalker implements TreeWalker
// FIXME: Composite key support, or select all columns? Does that make
// FIXME: Composite key support, or select all columns? Does that make
// in a subquery?
// in a subquery?
$class
=
$this
->
_queryComponents
[
$expr
][
'metadata'
];
$class
=
$this
->
_queryComponents
[
$expr
][
'metadata'
];
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$expr
)
.
'.'
;
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$expr
)
.
'.'
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getColumnName
(
$class
->
identifier
[
0
]));
.
$this
->
_conn
->
quoteIdentifier
(
$class
->
getColumnName
(
$class
->
identifier
[
0
]));
}
}
return
$sql
;
return
$sql
;
...
@@ -680,21 +863,16 @@ class SqlWalker implements TreeWalker
...
@@ -680,21 +863,16 @@ class SqlWalker implements TreeWalker
public
function
walkAggregateExpression
(
$aggExpression
)
public
function
walkAggregateExpression
(
$aggExpression
)
{
{
$sql
=
''
;
$sql
=
''
;
$parts
=
$aggExpression
->
pathExpression
->
getParts
()
;
$parts
=
$aggExpression
->
pathExpression
->
parts
;
$dqlAlias
=
$aggExpression
->
pathExpression
->
getIdentificationVariable
()
;
$dqlAlias
=
$aggExpression
->
pathExpression
->
identificationVariable
;
$fieldName
=
$parts
[
0
];
$fieldName
=
$parts
[
0
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$fieldName
);
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$fieldName
);
$sql
.=
$aggExpression
->
functionName
.
'('
;
return
$aggExpression
->
functionName
.
'('
.
(
$aggExpression
->
isDistinct
?
'DISTINCT '
:
''
)
.
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
if
(
$aggExpression
->
isDistinct
)
$sql
.=
'DISTINCT '
;
$sql
.=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
')'
;
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
')'
;
return
$sql
;
}
}
/**
/**
...
@@ -706,7 +884,7 @@ class SqlWalker implements TreeWalker
...
@@ -706,7 +884,7 @@ class SqlWalker implements TreeWalker
public
function
walkGroupByClause
(
$groupByClause
)
public
function
walkGroupByClause
(
$groupByClause
)
{
{
return
' GROUP BY '
.
implode
(
return
' GROUP BY '
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkGroupByItem'
),
$groupByClause
->
g
etGroupByItems
()
)
', '
,
array_map
(
array
(
$this
,
'walkGroupByItem'
),
$groupByClause
->
g
roupByItems
)
);
);
}
}
...
@@ -718,8 +896,8 @@ class SqlWalker implements TreeWalker
...
@@ -718,8 +896,8 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkGroupByItem
(
AST\PathExpression
$pathExpr
)
public
function
walkGroupByItem
(
AST\PathExpression
$pathExpr
)
{
{
$parts
=
$pathExpr
->
getParts
()
;
$parts
=
$pathExpr
->
parts
;
$dqlAlias
=
$pathExpr
->
getIdentificationVariable
()
;
$dqlAlias
=
$pathExpr
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
...
@@ -727,46 +905,6 @@ class SqlWalker implements TreeWalker
...
@@ -727,46 +905,6 @@ class SqlWalker implements TreeWalker
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
);
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
);
}
}
/**
* Walks down an UpdateStatement AST node, thereby generating the appropriate SQL.
*
* @param UpdateStatement
* @return string The SQL.
*/
public
function
walkUpdateStatement
(
AST\UpdateStatement
$AST
)
{
$this
->
_useSqlTableAliases
=
false
;
$sql
=
$this
->
walkUpdateClause
(
$AST
->
getUpdateClause
());
if
(
$whereClause
=
$AST
->
getWhereClause
())
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
}
return
$sql
;
}
/**
* Walks down a DeleteStatement AST node, thereby generating the appropriate SQL.
*
* @param DeleteStatement
* @return string The SQL.
*/
public
function
walkDeleteStatement
(
AST\DeleteStatement
$AST
)
{
$this
->
_useSqlTableAliases
=
false
;
$sql
=
$this
->
walkDeleteClause
(
$AST
->
getDeleteClause
());
if
(
$whereClause
=
$AST
->
getWhereClause
())
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
}
return
$sql
;
}
/**
/**
* Walks down a DeleteClause AST node, thereby generating the appropriate SQL.
* Walks down a DeleteClause AST node, thereby generating the appropriate SQL.
*
*
...
@@ -776,14 +914,14 @@ class SqlWalker implements TreeWalker
...
@@ -776,14 +914,14 @@ class SqlWalker implements TreeWalker
public
function
walkDeleteClause
(
AST\DeleteClause
$deleteClause
)
public
function
walkDeleteClause
(
AST\DeleteClause
$deleteClause
)
{
{
$sql
=
'DELETE FROM '
;
$sql
=
'DELETE FROM '
;
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
getAbstractSchemaName
()
);
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
abstractSchemaName
);
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
if
(
$this
->
_useSqlTableAliases
)
{
if
(
$this
->
_useSqlTableAliases
)
{
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
}
}
$this
->
_currentRootAlias
=
$deleteClause
->
getAliasIdentificationVariable
()
;
$this
->
_currentRootAlias
=
$deleteClause
->
aliasIdentificationVariable
;
return
$sql
;
return
$sql
;
}
}
...
@@ -797,17 +935,17 @@ class SqlWalker implements TreeWalker
...
@@ -797,17 +935,17 @@ class SqlWalker implements TreeWalker
public
function
walkUpdateClause
(
$updateClause
)
public
function
walkUpdateClause
(
$updateClause
)
{
{
$sql
=
'UPDATE '
;
$sql
=
'UPDATE '
;
$class
=
$this
->
_em
->
getClassMetadata
(
$updateClause
->
getAbstractSchemaName
()
);
$class
=
$this
->
_em
->
getClassMetadata
(
$updateClause
->
abstractSchemaName
);
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
if
(
$this
->
_useSqlTableAliases
)
{
if
(
$this
->
_useSqlTableAliases
)
{
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
}
}
$this
->
_currentRootAlias
=
$updateClause
->
getAliasIdentificationVariable
()
;
$this
->
_currentRootAlias
=
$updateClause
->
aliasIdentificationVariable
;
$sql
.=
' SET '
.
implode
(
$sql
.=
' SET '
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkUpdateItem'
),
$updateClause
->
getUpdateItems
()
)
', '
,
array_map
(
array
(
$this
,
'walkUpdateItem'
),
$updateClause
->
updateItems
)
);
);
return
$sql
;
return
$sql
;
...
@@ -825,16 +963,16 @@ class SqlWalker implements TreeWalker
...
@@ -825,16 +963,16 @@ class SqlWalker implements TreeWalker
$this
->
_useSqlTableAliases
=
false
;
$this
->
_useSqlTableAliases
=
false
;
$sql
=
''
;
$sql
=
''
;
$dqlAlias
=
$updateItem
->
getIdentificationVariable
()
;
$dqlAlias
=
$updateItem
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
if
(
$this
->
_useSqlTableAliases
)
{
if
(
$this
->
_useSqlTableAliases
)
{
$sql
.=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
())
.
'.'
;
$sql
.=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
())
.
'.'
;
}
}
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$qComp
[
'metadata'
]
->
getColumnName
(
$updateItem
->
getField
()
))
.
' = '
;
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$qComp
[
'metadata'
]
->
getColumnName
(
$updateItem
->
field
))
.
' = '
;
$newValue
=
$updateItem
->
getNewValue
()
;
$newValue
=
$updateItem
->
newValue
;
if
(
$newValue
instanceof
AST\Node
)
{
if
(
$newValue
instanceof
AST\Node
)
{
$sql
.=
$newValue
->
dispatch
(
$this
);
$sql
.=
$newValue
->
dispatch
(
$this
);
...
@@ -860,10 +998,10 @@ class SqlWalker implements TreeWalker
...
@@ -860,10 +998,10 @@ class SqlWalker implements TreeWalker
public
function
walkWhereClause
(
$whereClause
)
public
function
walkWhereClause
(
$whereClause
)
{
{
$sql
=
' WHERE '
;
$sql
=
' WHERE '
;
$condExpr
=
$whereClause
->
getConditionalExpression
()
;
$condExpr
=
$whereClause
->
conditionalExpression
;
$sql
.=
implode
(
$sql
.=
implode
(
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
getConditionalTerms
()
)
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
conditionalTerms
)
);
);
$discrSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
);
$discrSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
);
...
@@ -919,7 +1057,7 @@ class SqlWalker implements TreeWalker
...
@@ -919,7 +1057,7 @@ class SqlWalker implements TreeWalker
public
function
walkConditionalTerm
(
$condTerm
)
public
function
walkConditionalTerm
(
$condTerm
)
{
{
return
implode
(
return
implode
(
' AND '
,
array_map
(
array
(
$this
,
'walkConditionalFactor'
),
$condTerm
->
getConditionalFactors
()
)
' AND '
,
array_map
(
array
(
$this
,
'walkConditionalFactor'
),
$condTerm
->
conditionalFactors
)
);
);
}
}
...
@@ -931,18 +1069,17 @@ class SqlWalker implements TreeWalker
...
@@ -931,18 +1069,17 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkConditionalFactor
(
$factor
)
public
function
walkConditionalFactor
(
$factor
)
{
{
$sql
=
''
;
$sql
=
(
$factor
->
not
)
?
'NOT '
:
''
;
if
(
$factor
->
isNot
())
$sql
.=
'NOT '
;
$primary
=
$factor
->
conditionalPrimary
;
$primary
=
$factor
->
getConditionalPrimary
();
if
(
$primary
->
isSimpleConditionalExpression
())
{
if
(
$primary
->
isSimpleConditionalExpression
())
{
$sql
.=
$primary
->
getSimpleConditionalExpression
()
->
dispatch
(
$this
);
$sql
.=
$primary
->
simpleConditionalExpression
->
dispatch
(
$this
);
}
else
if
(
$primary
->
isConditionalExpression
())
{
}
else
if
(
$primary
->
isConditionalExpression
())
{
$condExpr
=
$primary
->
getConditionalExpression
();
$condExpr
=
$primary
->
conditionalExpression
;
$sql
.=
'('
.
implode
(
$sql
.=
'('
.
implode
(
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
getConditionalTerms
()
)
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
conditionalTerms
)
)
.
')'
;
)
.
')'
;
}
}
...
@@ -957,11 +1094,9 @@ class SqlWalker implements TreeWalker
...
@@ -957,11 +1094,9 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkExistsExpression
(
$existsExpr
)
public
function
walkExistsExpression
(
$existsExpr
)
{
{
$sql
=
''
;
$sql
=
(
$existsExpr
->
not
)
?
'NOT '
:
''
;
if
(
$existsExpr
->
isNot
())
$sql
.=
' NOT'
;
$sql
.=
'EXISTS ('
.
$this
->
walkSubselect
(
$existsExpr
->
subselect
)
.
')'
;
$sql
.=
'EXISTS ('
.
$this
->
walkSubselect
(
$existsExpr
->
getSubselect
())
.
')'
;
return
$sql
;
return
$sql
;
}
}
...
@@ -974,17 +1109,17 @@ class SqlWalker implements TreeWalker
...
@@ -974,17 +1109,17 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkCollectionMemberExpression
(
$collMemberExpr
)
public
function
walkCollectionMemberExpression
(
$collMemberExpr
)
{
{
$sql
=
$collMemberExpr
->
isN
ot
?
'NOT '
:
''
;
$sql
=
$collMemberExpr
->
n
ot
?
'NOT '
:
''
;
$sql
.=
'EXISTS (SELECT 1 FROM '
;
$sql
.=
'EXISTS (SELECT 1 FROM '
;
$entityExpr
=
$collMemberExpr
->
entityExpression
;
$entityExpr
=
$collMemberExpr
->
entityExpression
;
$collPathExpr
=
$collMemberExpr
->
collectionValuedPathExpression
;
$collPathExpr
=
$collMemberExpr
->
collectionValuedPathExpression
;
$parts
=
$collPathExpr
->
getParts
()
;
$parts
=
$collPathExpr
->
parts
;
$dqlAlias
=
$collPathExpr
->
getIdentificationVariable
()
;
$dqlAlias
=
$collPathExpr
->
identificationVariable
;
$class
=
$this
->
_queryComponents
[
$dqlAlias
][
'metadata'
];
$class
=
$this
->
_queryComponents
[
$dqlAlias
][
'metadata'
];
if
(
$entityExpr
instanceof
AST\InputParameter
)
{
if
(
$entityExpr
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$entityExpr
->
isNamed
()
?
$entityExpr
->
getName
()
:
$entityExpr
->
getPosition
()
;
$dqlParamKey
=
$entityExpr
->
name
;
$entity
=
$this
->
_query
->
getParameter
(
$dqlParamKey
);
$entity
=
$this
->
_query
->
getParameter
(
$dqlParamKey
);
}
else
{
}
else
{
//TODO
//TODO
...
@@ -1026,7 +1161,9 @@ class SqlWalker implements TreeWalker
...
@@ -1026,7 +1161,9 @@ class SqlWalker implements TreeWalker
}
else
{
// many-to-many
}
else
{
// many-to-many
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$assoc
->
targetEntityName
);
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$assoc
->
targetEntityName
);
$sourceTableAlias
=
$this
->
getSqlTableAlias
(
$class
->
primaryTable
[
'name'
],
$dqlAlias
);
$sourceTableAlias
=
$this
->
getSqlTableAlias
(
$class
->
primaryTable
[
'name'
],
$dqlAlias
);
$joinTable
=
$assoc
->
isOwningSide
?
$assoc
->
joinTable
:
$targetClass
->
associationMappings
[
$assoc
->
mappedByFieldName
]
->
joinTable
;
$joinTable
=
$assoc
->
isOwningSide
?
$assoc
->
joinTable
:
$targetClass
->
associationMappings
[
$assoc
->
mappedByFieldName
]
->
joinTable
;
$joinTableAlias
=
$this
->
getSqlTableAlias
(
$joinTable
[
'name'
]);
$joinTableAlias
=
$this
->
getSqlTableAlias
(
$joinTable
[
'name'
]);
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetClass
->
primaryTable
[
'name'
]);
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetClass
->
primaryTable
[
'name'
]);
...
@@ -1037,7 +1174,9 @@ class SqlWalker implements TreeWalker
...
@@ -1037,7 +1174,9 @@ class SqlWalker implements TreeWalker
.
' '
.
$targetTableAlias
.
' ON '
;
.
' '
.
$targetTableAlias
.
' ON '
;
// join conditions
// join conditions
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'joinColumns'
]
:
$joinTable
[
'inverseJoinColumns'
];
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'joinColumns'
]
:
$joinTable
[
'inverseJoinColumns'
];
$first
=
true
;
$first
=
true
;
foreach
(
$joinColumns
as
$joinColumn
)
{
foreach
(
$joinColumns
as
$joinColumn
)
{
...
@@ -1050,7 +1189,9 @@ class SqlWalker implements TreeWalker
...
@@ -1050,7 +1189,9 @@ class SqlWalker implements TreeWalker
$sql
.=
' WHERE '
;
$sql
.=
' WHERE '
;
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'inverseJoinColumns'
]
:
$joinTable
[
'joinColumns'
];
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'inverseJoinColumns'
]
:
$joinTable
[
'joinColumns'
];
$first
=
true
;
$first
=
true
;
foreach
(
$joinColumns
as
$joinColumn
)
{
foreach
(
$joinColumns
as
$joinColumn
)
{
...
@@ -1085,12 +1226,9 @@ class SqlWalker implements TreeWalker
...
@@ -1085,12 +1226,9 @@ class SqlWalker implements TreeWalker
public
function
walkEmptyCollectionComparisonExpression
(
$emptyCollCompExpr
)
public
function
walkEmptyCollectionComparisonExpression
(
$emptyCollCompExpr
)
{
{
$sizeFunc
=
new
AST\Functions\SizeFunction
(
'size'
);
$sizeFunc
=
new
AST\Functions\SizeFunction
(
'size'
);
$sizeFunc
->
setCollectionPathExpression
(
$emptyCollCompExpr
->
getExpression
());
$sizeFunc
->
collectionPathExpression
=
$emptyCollCompExpr
->
expression
;
$sql
=
$sizeFunc
->
getSql
(
$this
);
$sql
.=
(
$emptyCollCompExpr
->
isNot
()
?
' > 0'
:
' = 0'
);
return
$s
ql
;
return
$s
izeFunc
->
getSql
(
$this
)
.
(
$emptyCollCompExpr
->
not
?
' > 0'
:
' = 0'
)
;
}
}
/**
/**
...
@@ -1102,17 +1240,17 @@ class SqlWalker implements TreeWalker
...
@@ -1102,17 +1240,17 @@ class SqlWalker implements TreeWalker
public
function
walkNullComparisonExpression
(
$nullCompExpr
)
public
function
walkNullComparisonExpression
(
$nullCompExpr
)
{
{
$sql
=
''
;
$sql
=
''
;
$innerExpr
=
$nullCompExpr
->
getExpression
()
;
$innerExpr
=
$nullCompExpr
->
expression
;
if
(
$innerExpr
instanceof
AST\InputParameter
)
{
if
(
$innerExpr
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$innerExpr
->
isNamed
()
?
$innerExpr
->
getName
()
:
$innerExpr
->
getPosition
()
;
$dqlParamKey
=
$innerExpr
->
name
;
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$sql
.=
' ?'
;
// . ($innerExpr->isNamed() ? ':' . $innerExpr->getName() : '?');
$sql
.=
' ?'
;
}
else
{
}
else
{
$sql
.=
$this
->
walkPathExpression
(
$innerExpr
);
$sql
.=
$this
->
walkPathExpression
(
$innerExpr
);
}
}
$sql
.=
' IS'
.
(
$nullCompExpr
->
isNot
()
?
' NOT'
:
''
)
.
' NULL'
;
$sql
.=
' IS'
.
(
$nullCompExpr
->
not
?
' NOT'
:
''
)
.
' NULL'
;
return
$sql
;
return
$sql
;
}
}
...
@@ -1125,16 +1263,13 @@ class SqlWalker implements TreeWalker
...
@@ -1125,16 +1263,13 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkInExpression
(
$inExpr
)
public
function
walkInExpression
(
$inExpr
)
{
{
$sql
=
$this
->
walkPathExpression
(
$inExpr
->
getPathExpression
());
$sql
=
$this
->
walkPathExpression
(
$inExpr
->
pathExpression
)
.
(
$inExpr
->
not
?
' NOT'
:
''
)
.
' IN ('
;
if
(
$inExpr
->
isNot
())
$sql
.=
' NOT'
;
if
(
$inExpr
->
subselect
)
{
$sql
.=
$this
->
walkSubselect
(
$inExpr
->
subselect
);
$sql
.=
' IN ('
;
if
(
$inExpr
->
getSubselect
())
{
$sql
.=
$this
->
walkSubselect
(
$inExpr
->
getSubselect
());
}
else
{
}
else
{
$sql
.=
implode
(
', '
,
array_map
(
array
(
$this
,
'walkLiteral'
),
$inExpr
->
getLiterals
()
));
$sql
.=
implode
(
', '
,
array_map
(
array
(
$this
,
'walkLiteral'
),
$inExpr
->
literals
));
}
}
$sql
.=
')'
;
$sql
.=
')'
;
...
@@ -1151,10 +1286,7 @@ class SqlWalker implements TreeWalker
...
@@ -1151,10 +1286,7 @@ class SqlWalker implements TreeWalker
public
function
walkLiteral
(
$literal
)
public
function
walkLiteral
(
$literal
)
{
{
if
(
$literal
instanceof
AST\InputParameter
)
{
if
(
$literal
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$literal
->
isNamed
()
?
$literal
->
getName
()
:
$literal
->
getPosition
();
return
$this
->
walkInputParameter
(
$literal
);
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
return
'?'
;
}
}
return
$literal
;
//TODO: quote() ?
return
$literal
;
//TODO: quote() ?
...
@@ -1168,12 +1300,12 @@ class SqlWalker implements TreeWalker
...
@@ -1168,12 +1300,12 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkBetweenExpression
(
$betweenExpr
)
public
function
walkBetweenExpression
(
$betweenExpr
)
{
{
$sql
=
$this
->
walkArithmeticExpression
(
$betweenExpr
->
getBaseExpression
()
);
$sql
=
$this
->
walkArithmeticExpression
(
$betweenExpr
->
expression
);
if
(
$betweenExpr
->
getNot
()
)
$sql
.=
' NOT'
;
if
(
$betweenExpr
->
not
)
$sql
.=
' NOT'
;
$sql
.=
' BETWEEN '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
getLeftBetweenExpression
()
)
$sql
.=
' BETWEEN '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
leftBetweenExpression
)
.
' AND '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
getRightBetweenExpression
()
);
.
' AND '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
rightBetweenExpression
);
return
$sql
;
return
$sql
;
}
}
...
@@ -1186,24 +1318,20 @@ class SqlWalker implements TreeWalker
...
@@ -1186,24 +1318,20 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkLikeExpression
(
$likeExpr
)
public
function
walkLikeExpression
(
$likeExpr
)
{
{
$stringExpr
=
$likeExpr
->
getStringExpression
();
$stringExpr
=
$likeExpr
->
stringExpression
;
$sql
=
$stringExpr
->
dispatch
(
$this
);
$sql
=
$stringExpr
->
dispatch
(
$this
)
.
(
$likeExpr
->
not
?
' NOT'
:
''
)
.
' LIKE '
;
if
(
$likeExpr
->
isNot
())
$sql
.=
' NOT'
;
$sql
.=
' LIKE '
;
if
(
$likeExpr
->
stringPattern
instanceof
AST\InputParameter
)
{
$inputParam
=
$likeExpr
->
stringPattern
;
if
(
$likeExpr
->
getStringPattern
()
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$inputParam
->
name
;
$inputParam
=
$likeExpr
->
getStringPattern
();
$dqlParamKey
=
$inputParam
->
isNamed
()
?
$inputParam
->
getName
()
:
$inputParam
->
getPosition
();
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$sql
.=
'?'
;
$sql
.=
'?'
;
}
else
{
}
else
{
$sql
.=
$this
->
_conn
->
quote
(
$likeExpr
->
getStringPattern
()
);
$sql
.=
$this
->
_conn
->
quote
(
$likeExpr
->
stringPattern
);
}
}
if
(
$likeExpr
->
getEscapeChar
()
)
{
if
(
$likeExpr
->
escapeChar
)
{
$sql
.=
' ESCAPE '
.
$this
->
_conn
->
quote
(
$likeExpr
->
getEscapeChar
()
);
$sql
.=
' ESCAPE '
.
$this
->
_conn
->
quote
(
$likeExpr
->
escapeChar
);
}
}
return
$sql
;
return
$sql
;
...
@@ -1229,8 +1357,8 @@ class SqlWalker implements TreeWalker
...
@@ -1229,8 +1357,8 @@ class SqlWalker implements TreeWalker
public
function
walkComparisonExpression
(
$compExpr
)
public
function
walkComparisonExpression
(
$compExpr
)
{
{
$sql
=
''
;
$sql
=
''
;
$leftExpr
=
$compExpr
->
getLeftExpression
()
;
$leftExpr
=
$compExpr
->
leftExpression
;
$rightExpr
=
$compExpr
->
getRightExpression
()
;
$rightExpr
=
$compExpr
->
rightExpression
;
if
(
$leftExpr
instanceof
AST\Node
)
{
if
(
$leftExpr
instanceof
AST\Node
)
{
$sql
.=
$leftExpr
->
dispatch
(
$this
);
$sql
.=
$leftExpr
->
dispatch
(
$this
);
...
@@ -1238,7 +1366,7 @@ class SqlWalker implements TreeWalker
...
@@ -1238,7 +1366,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_conn
->
quote
(
$leftExpr
);
$sql
.=
$this
->
_conn
->
quote
(
$leftExpr
);
}
}
$sql
.=
' '
.
$compExpr
->
getOperator
()
.
' '
;
$sql
.=
' '
.
$compExpr
->
operator
.
' '
;
if
(
$rightExpr
instanceof
AST\Node
)
{
if
(
$rightExpr
instanceof
AST\Node
)
{
$sql
.=
$rightExpr
->
dispatch
(
$this
);
$sql
.=
$rightExpr
->
dispatch
(
$this
);
...
@@ -1257,8 +1385,7 @@ class SqlWalker implements TreeWalker
...
@@ -1257,8 +1385,7 @@ class SqlWalker implements TreeWalker
*/
*/
public
function
walkInputParameter
(
$inputParam
)
public
function
walkInputParameter
(
$inputParam
)
{
{
$dqlParamKey
=
$inputParam
->
isNamed
()
?
$inputParam
->
getName
()
:
$inputParam
->
getPosition
();
$this
->
_parserResult
->
addParameterMapping
(
$inputParam
->
name
,
$this
->
_sqlParamIndex
++
);
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
return
'?'
;
return
'?'
;
}
}
...
@@ -1287,7 +1414,7 @@ class SqlWalker implements TreeWalker
...
@@ -1287,7 +1414,7 @@ class SqlWalker implements TreeWalker
if
(
is_string
(
$term
))
return
$term
;
if
(
is_string
(
$term
))
return
$term
;
return
implode
(
return
implode
(
' '
,
array_map
(
array
(
$this
,
'walkArithmeticFactor'
),
$term
->
getArithmeticFactors
()
)
' '
,
array_map
(
array
(
$this
,
'walkArithmeticFactor'
),
$term
->
arithmeticFactors
)
);
);
}
}
...
@@ -1314,11 +1441,11 @@ class SqlWalker implements TreeWalker
...
@@ -1314,11 +1441,11 @@ class SqlWalker implements TreeWalker
{
{
if
(
is_string
(
$factor
))
return
$factor
;
if
(
is_string
(
$factor
))
return
$factor
;
$sql
=
''
;
$sql
=
(
$factor
->
isNegativeSigned
()
?
'-'
:
(
$factor
->
isPositiveSigned
()
?
'+'
:
''
))
;
$primary
=
$factor
->
getArithmeticPrimary
()
;
$primary
=
$factor
->
arithmeticPrimary
;
if
(
is_numeric
(
$primary
))
{
if
(
is_numeric
(
$primary
))
{
$sql
.=
$primary
;
//
TODO: quote() ?
$sql
.=
$primary
;
//
We should not quote numeric values!
}
else
if
(
is_string
(
$primary
))
{
}
else
if
(
is_string
(
$primary
))
{
$sql
.=
$this
->
_conn
->
quote
(
$primary
);
$sql
.=
$this
->
_conn
->
quote
(
$primary
);
}
else
if
(
$primary
instanceof
AST\SimpleArithmeticExpression
)
{
}
else
if
(
$primary
instanceof
AST\SimpleArithmeticExpression
)
{
...
@@ -1339,7 +1466,7 @@ class SqlWalker implements TreeWalker
...
@@ -1339,7 +1466,7 @@ class SqlWalker implements TreeWalker
public
function
walkSimpleArithmeticExpression
(
$simpleArithmeticExpr
)
public
function
walkSimpleArithmeticExpression
(
$simpleArithmeticExpr
)
{
{
return
implode
(
return
implode
(
' '
,
array_map
(
array
(
$this
,
'walkArithmeticTerm'
),
$simpleArithmeticExpr
->
getArithmeticTerms
()
)
' '
,
array_map
(
array
(
$this
,
'walkArithmeticTerm'
),
$simpleArithmeticExpr
->
arithmeticTerms
)
);
);
}
}
...
@@ -1352,13 +1479,13 @@ class SqlWalker implements TreeWalker
...
@@ -1352,13 +1479,13 @@ class SqlWalker implements TreeWalker
public
function
walkPathExpression
(
$pathExpr
)
public
function
walkPathExpression
(
$pathExpr
)
{
{
$sql
=
''
;
$sql
=
''
;
$pathExprType
=
$pathExpr
->
getType
()
;
$pathExprType
=
$pathExpr
->
type
;
if
(
$pathExprType
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
if
(
$pathExprType
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
$parts
=
$pathExpr
->
getParts
()
;
$parts
=
$pathExpr
->
parts
;
$numParts
=
count
(
$parts
);
$numParts
=
count
(
$parts
);
$dqlAlias
=
$pathExpr
->
getIdentificationVariable
()
;
$dqlAlias
=
$pathExpr
->
identificationVariable
;
$fieldName
=
$parts
[
$numParts
-
1
];
$fieldName
=
$parts
[
$numParts
-
1
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$class
=
$qComp
[
'metadata'
];
$class
=
$qComp
[
'metadata'
];
...
@@ -1390,130 +1517,4 @@ class SqlWalker implements TreeWalker
...
@@ -1390,130 +1517,4 @@ class SqlWalker implements TreeWalker
return
$sql
;
return
$sql
;
}
}
/**
* Generates a unique, short SQL table alias.
*
* @param string $dqlAlias The DQL alias.
* @return string Generated table alias.
*/
public
function
getSqlTableAlias
(
$tableName
,
$dqlAlias
=
''
)
{
$tableName
.=
$dqlAlias
;
if
(
!
isset
(
$this
->
_dqlToSqlAliasMap
[
$tableName
]))
{
$this
->
_dqlToSqlAliasMap
[
$tableName
]
=
strtolower
(
substr
(
$tableName
,
0
,
1
))
.
$this
->
_tableAliasCounter
++
.
'_'
;
}
return
$this
->
_dqlToSqlAliasMap
[
$tableName
];
}
/**
* Forces the SqlWalker to use a specific alias for a table name, rather than
* generating an alias on its own.
*
* @param string $tableName
* @param string $alias
*/
public
function
setSqlTableAlias
(
$tableName
,
$alias
)
{
$this
->
_dqlToSqlAliasMap
[
$tableName
]
=
$alias
;
}
/**
* Gets an SQL column alias for a column name.
*
* @param string $columnName
* @return string
*/
public
function
getSqlColumnAlias
(
$columnName
)
{
return
trim
(
$columnName
,
'`'
)
.
$this
->
_aliasCounter
++
;
}
/**
* Generates the SQL JOINs that are necessary for Class Table Inheritance
* for the given class.
*
* @param ClassMetadata $class The class for which to generate the joins.
* @param string $dqlAlias The DQL alias of the class.
* @return string The SQL.
*/
private
function
_generateClassTableInheritanceJoins
(
$class
,
$dqlAlias
)
{
$sql
=
''
;
$baseTableAlias
=
$this
->
getSqlTableAlias
(
$class
->
primaryTable
[
'name'
],
$dqlAlias
);
$idColumns
=
$class
->
getIdentifierColumnNames
();
// INNER JOIN parent class tables
foreach
(
$class
->
parentClasses
as
$parentClassName
)
{
$parentClass
=
$this
->
_em
->
getClassMetadata
(
$parentClassName
);
$tableAlias
=
$this
->
getSqlTableAlias
(
$parentClass
->
primaryTable
[
'name'
],
$dqlAlias
);
$sql
.=
' INNER JOIN '
.
$this
->
_conn
->
quoteIdentifier
(
$parentClass
->
primaryTable
[
'name'
])
.
' '
.
$tableAlias
.
' ON '
;
$first
=
true
;
foreach
(
$idColumns
as
$idColumn
)
{
if
(
$first
)
$first
=
false
;
else
$sql
.=
' AND '
;
$sql
.=
$baseTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
)
.
' = '
.
$tableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
);
}
}
// LEFT JOIN subclass tables
foreach
(
$class
->
subClasses
as
$subClassName
)
{
$subClass
=
$this
->
_em
->
getClassMetadata
(
$subClassName
);
$tableAlias
=
$this
->
getSqlTableAlias
(
$subClass
->
primaryTable
[
'name'
],
$dqlAlias
);
$sql
.=
' LEFT JOIN '
.
$subClass
->
primaryTable
[
'name'
]
.
' '
.
$tableAlias
.
' ON '
;
$first
=
true
;
foreach
(
$idColumns
as
$idColumn
)
{
if
(
$first
)
$first
=
false
;
else
$sql
.=
' AND '
;
$sql
.=
$baseTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
)
.
' = '
.
$tableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$idColumn
);
}
}
return
$sql
;
}
/**
* Gets an executor that can be used to execute the result of this walker.
*
* @return AbstractExecutor
*/
public
function
getExecutor
(
$AST
)
{
$isDeleteStatement
=
$AST
instanceof
AST\DeleteStatement
;
$isUpdateStatement
=
$AST
instanceof
AST\UpdateStatement
;
if
(
$isDeleteStatement
)
{
$primaryClass
=
$this
->
_em
->
getClassMetadata
(
$AST
->
getDeleteClause
()
->
getAbstractSchemaName
()
);
if
(
$primaryClass
->
isInheritanceTypeJoined
())
{
return
new
Exec\MultiTableDeleteExecutor
(
$AST
,
$this
);
}
else
{
return
new
Exec\SingleTableDeleteUpdateExecutor
(
$AST
,
$this
);
}
}
else
if
(
$isUpdateStatement
)
{
$primaryClass
=
$this
->
_em
->
getClassMetadata
(
$AST
->
getUpdateClause
()
->
getAbstractSchemaName
()
);
if
(
$primaryClass
->
isInheritanceTypeJoined
())
{
return
new
Exec\MultiTableUpdateExecutor
(
$AST
,
$this
);
}
else
{
return
new
Exec\SingleTableDeleteUpdateExecutor
(
$AST
,
$this
);
}
}
else
{
return
new
Exec\SingleSelectExecutor
(
$AST
,
$this
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment