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;
* point of abstraction of platform-specific behaviors, features and SQL dialects.
* 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
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
...
...
lib/Doctrine/ORM/AbstractQuery.php
View file @
33fc28ff
...
...
@@ -21,6 +21,8 @@
namespace
Doctrine\ORM
;
use
Doctrine\ORM\Query\QueryException
;
/**
* Base class for Query and NativeQuery.
*
...
...
lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,34 +24,40 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_arithmeticPrimary
;
private
$_pSigned
;
private
$_nSigned
;
/**
* @var ArithmeticPrimary
*/
public
$arithmeticPrimary
;
public
function
__construct
(
$arithmeticPrimary
,
$pSigned
=
false
,
$nSigned
=
false
)
{
$this
->
_arithmeticPrimary
=
$arithmeticPrimary
;
$this
->
_pSigned
=
$pSigned
;
$this
->
_nSigned
=
$nSigned
;
}
/**
* @var null|boolean NULL represents no sign, TRUE means positive and FALSE means negative sign
*/
public
$sign
;
public
function
getArithmeticPrimary
(
)
public
function
__construct
(
$arithmeticPrimary
,
$sign
=
null
)
{
return
$this
->
_arithmeticPrimary
;
$this
->
arithmeticPrimary
=
$arithmeticPrimary
;
$this
->
sign
=
$sign
;
}
public
function
isPositiveSigned
()
{
return
$this
->
_pSigned
;
return
$this
->
sign
===
true
;
}
public
function
isNegativeSigned
()
{
return
$this
->
_nSigned
;
return
$this
->
sign
===
false
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_f
actors
;
p
ublic
$arithmeticF
actors
;
public
function
__construct
(
array
$arithmeticFactors
)
{
$this
->
_factors
=
$arithmeticFactors
;
}
public
function
getArithmeticFactors
()
{
return
$this
->
_factors
;
$this
->
arithmeticFactors
=
$arithmeticFactors
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/BetweenExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,45 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_baseExpression
;
private
$_leftBetweenExpression
;
private
$_rightBetweenExpression
;
private
$_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
$expression
;
public
$leftBetweenExpression
;
public
$rightBetweenExpression
;
public
$not
;
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
)
...
...
lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php
View file @
33fc28ff
<?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
;
/**
* 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>
*/
class
CollectionMemberExpression
extends
Node
{
public
$entityExpression
;
public
$collectionValuedPathExpression
;
public
$
isN
ot
;
public
$
n
ot
;
public
function
__construct
(
$entityExpr
,
$collValuedPathExpr
,
$isNot
)
public
function
__construct
(
$entityExpr
,
$collValuedPathExpr
)
{
$this
->
entityExpression
=
$entityExpr
;
$this
->
collectionValuedPathExpression
=
$collValuedPathExpr
;
$this
->
isNot
=
$isNot
;
}
public
function
dispatch
(
$walker
)
...
...
lib/Doctrine/ORM/Query/AST/ComparisonExpression.php
View file @
33fc28ff
...
...
@@ -29,34 +29,25 @@ namespace Doctrine\ORM\Query\AST;
* DatetimeExpression ComparisonOperator (DatetimeExpression | 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
{
p
rivate
$_leftExpr
;
p
rivate
$_rightExpr
;
p
rivate
$_
operator
;
p
ublic
$leftExpression
;
p
ublic
$rightExpression
;
p
ublic
$
operator
;
public
function
__construct
(
$leftExpr
,
$operator
,
$rightExpr
)
{
$this
->
_leftExpr
=
$leftExpr
;
$this
->
_rightExpr
=
$rightExpr
;
$this
->
_operator
=
$operator
;
}
public
function
getLeftExpression
()
{
return
$this
->
_leftExpr
;
}
public
function
getRightExpression
()
{
return
$this
->
_rightExpr
;
}
public
function
getOperator
()
{
return
$this
->
_operator
;
$this
->
leftExpression
=
$leftExpr
;
$this
->
rightExpression
=
$rightExpr
;
$this
->
operator
=
$operator
;
}
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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
conditionalTerms
=
array
();
p
ublic
$
conditionalTerms
=
array
();
public
function
__construct
(
array
$conditionalTerms
)
{
$this
->
_conditionalTerms
=
$conditionalTerms
;
}
public
function
getConditionalTerms
()
{
return
$this
->
_conditionalTerms
;
$this
->
conditionalTerms
=
$conditionalTerms
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalFactor.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,27 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_not
=
false
;
private
$_conditionalPrimary
;
public
function
__construct
(
$conditionalPrimary
,
$not
=
false
)
{
$this
->
_conditionalPrimary
=
$conditionalPrimary
;
$this
->
_not
=
$not
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
public
$not
=
false
;
public
$conditionalPrimary
;
public
function
getConditionalPrimary
(
)
public
function
__construct
(
$conditionalPrimary
)
{
return
$this
->
_
conditionalPrimary
;
$this
->
conditionalPrimary
=
$
conditionalPrimary
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,41 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_simpleConditionalExpression
;
private
$_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
$simpleConditionalExpression
;
public
$conditionalExpression
;
public
function
isSimpleConditionalExpression
()
{
return
(
bool
)
$this
->
_
simpleConditionalExpression
;
return
(
bool
)
$this
->
simpleConditionalExpression
;
}
public
function
isConditionalExpression
()
{
return
(
bool
)
$this
->
_
conditionalExpression
;
return
(
bool
)
$this
->
conditionalExpression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ConditionalTerm.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
conditionalFactors
=
array
();
p
ublic
$
conditionalFactors
=
array
();
public
function
__construct
(
array
$conditionalFactors
)
{
$this
->
_conditionalFactors
=
$conditionalFactors
;
}
public
function
getConditionalFactors
()
{
return
$this
->
_conditionalFactors
;
$this
->
conditionalFactors
=
$conditionalFactors
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/DeleteClause.php
View file @
33fc28ff
...
...
@@ -23,30 +23,23 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
ublic
$
abstractSchemaName
;
p
ublic
$
aliasIdentificationVariable
;
public
function
__construct
(
$abstractSchemaName
)
{
$this
->
_abstractSchemaName
=
$abstractSchemaName
;
}
public
function
getAbstractSchemaName
()
{
return
$this
->
_abstractSchemaName
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
setAliasIdentificationVariable
(
$alias
)
{
$this
->
_aliasIdentificationVariable
=
$alias
;
$this
->
abstractSchemaName
=
$abstractSchemaName
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/DeleteStatement.php
View file @
33fc28ff
...
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* DeleteStatement = DeleteClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
p
rivate
$_
deleteClause
;
p
rivate
$_
whereClause
;
p
ublic
$
deleteClause
;
p
ublic
$
whereClause
;
public
function
__construct
(
$deleteClause
)
{
$this
->
_deleteClause
=
$deleteClause
;
}
public
function
setWhereClause
(
$whereClause
)
{
$this
->
_whereClause
=
$whereClause
;
}
public
function
getDeleteClause
()
{
return
$this
->
_deleteClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
$this
->
deleteClause
=
$deleteClause
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php
View file @
33fc28ff
<?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
;
/**
* 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 Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class
EmptyCollectionComparisonExpression
extends
Node
{
p
rivate
$_
expression
;
p
rivate
$_
not
;
p
ublic
$
expression
;
p
ublic
$
not
;
public
function
__construct
(
$expression
)
{
$this
->
_expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
$this
->
expression
=
$expression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/ExistsExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_not
=
false
;
p
rivate
$_
subselect
;
p
ublic
$not
;
p
ublic
$
subselect
;
public
function
__construct
(
$subselect
)
{
$this
->
_subselect
=
$subselect
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
}
public
function
getSubselect
()
{
return
$this
->
_subselect
;
$this
->
subselect
=
$subselect
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/FromClause.php
View file @
33fc28ff
...
...
@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.
phpdoctrine
.org>.
* <http://www.
doctrine-project
.org>.
*/
namespace
Doctrine\ORM\Query\AST
;
...
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
p
rotected
$_
identificationVariableDeclarations
=
array
();
p
ublic
$
identificationVariableDeclarations
=
array
();
public
function
__construct
(
array
$identificationVariableDeclarations
)
{
$this
->
_identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
/* Getters */
public
function
getIdentificationVariableDeclarations
()
{
return
$this
->
_identificationVariableDeclarations
;
$this
->
identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,24 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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>
*/
class
AbsFunction
extends
FunctionNode
{
private
$_simpleArithmeticExpression
;
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
public
$simpleArithmeticExpression
;
/**
* @override
*/
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//TODO: Use platform to get SQL
return
'ABS('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_simpleArithmeticExpression
)
.
')'
;
return
'ABS('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
simpleArithmeticExpression
)
.
')'
;
}
/**
...
...
@@ -37,7 +54,7 @@ class AbsFunction extends FunctionNode
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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>
*/
class
ConcatFunction
extends
FunctionNode
{
private
$_firstStringPrimary
;
private
$_secondStringPriamry
;
public
function
getFirstStringPrimary
()
{
return
$this
->
_firstStringPrimary
;
}
public
function
getSecondStringPrimary
()
{
return
$this
->
_secondStringPrimary
;
}
public
$firstStringPrimary
;
public
$secondStringPriamry
;
/**
* @override
...
...
@@ -33,8 +44,8 @@ class ConcatFunction extends FunctionNode
{
$platform
=
$sqlWalker
->
getConnection
()
->
getDatabasePlatform
();
return
$platform
->
getConcatExpression
(
$sqlWalker
->
walkStringPrimary
(
$this
->
_
firstStringPrimary
),
$sqlWalker
->
walkStringPrimary
(
$this
->
_
secondStringPrimary
)
$sqlWalker
->
walkStringPrimary
(
$this
->
firstStringPrimary
),
$sqlWalker
->
walkStringPrimary
(
$this
->
secondStringPrimary
)
);
}
...
...
@@ -47,9 +58,9 @@ class ConcatFunction extends FunctionNode
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_
firstStringPrimary
=
$parser
->
StringPrimary
();
$this
->
firstStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$this
->
_
secondStringPrimary
=
$parser
->
StringPrimary
();
$this
->
secondStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php
View file @
33fc28ff
<?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
;
/**
* "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
{
...
...
lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,7 +24,13 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
...
...
lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php
View file @
33fc28ff
...
...
@@ -24,22 +24,23 @@ namespace Doctrine\ORM\Query\AST\Functions;
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
{
p
rivate
$_
name
;
p
ublic
$
name
;
public
function
__construct
(
$name
)
{
$this
->
_name
=
$name
;
}
public
function
getName
()
{
return
$this
->
_name
;
$this
->
name
=
$name
;
}
abstract
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
);
...
...
lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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>
*/
class
LengthFunction
extends
FunctionNode
{
private
$_stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
$stringPrimary
;
/**
* @override
...
...
@@ -26,7 +42,7 @@ class LengthFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//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
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
private
$_firstStringPrimary
;
private
$_secondStringPrimary
;
private
$_simpleArithmeticExpression
;
public
function
getFirstStringPrimary
()
{
return
$this
->
_firstStringPrimary
;
}
public
function
getSecondStringPrimary
()
{
return
$this
->
_secondStringPrimary
;
}
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
public
$firstStringPrimary
;
public
$secondStringPrimary
;
public
$simpleArithmeticExpression
;
/**
* @override
...
...
@@ -38,15 +44,12 @@ class LocateFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//TODO: Use platform to get SQL
$sql
=
'LOCATE('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_firstStringPrimary
)
.
', '
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_secondStringPrimary
);
if
(
$this
->
_simpleArithmeticExpression
)
{
$sql
.=
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_simpleArithmeticExpression
);
}
return
$sql
.
')'
;
return
'LOCATE('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
firstStringPrimary
)
.
', '
.
$sqlWalker
->
walkStringPrimary
(
$this
->
secondStringPrimary
)
.
((
$this
->
simpleArithmeticExpression
)
?
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
simpleArithmeticExpression
)
:
''
)
.
')'
;
}
/**
...
...
@@ -55,15 +58,22 @@ class LocateFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_firstStringPrimary
=
$parser
->
StringPrimary
();
$this
->
firstStringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$this
->
_secondStringPrimary
=
$parser
->
StringPrimary
();
$this
->
secondStringPrimary
=
$parser
->
StringPrimary
();
if
(
$lexer
->
isNextToken
(
','
))
{
$parser
->
match
(
','
);
$this
->
_simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
}
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
private
$_stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
$stringPrimary
;
/**
* @override
...
...
@@ -26,7 +42,7 @@ class LowerFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//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
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,22 +24,18 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
private
$_firstSimpleArithmeticExpression
;
private
$_secondSimpleArithmeticExpression
;
public
function
getFirstSimpleArithmeticExpression
()
{
return
$this
->
_firstSimpleArithmeticExpression
;
}
public
function
getSecondSimpleArithmeticExpression
()
{
return
$this
->
_secondSimpleArithmeticExpression
;
}
public
$firstSimpleArithmeticExpression
;
public
$secondSimpleArithmeticExpression
;
/**
* @override
...
...
@@ -32,10 +43,10 @@ class ModFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//TODO: Use platform to get SQL
return
'SQRT('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_firstSimpleArithmeticExpression
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_secondSimpleArithmeticExpression
)
return
'SQRT('
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_firstSimpleArithmeticExpression
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_secondSimpleArithmeticExpression
)
.
')'
;
}
...
...
@@ -45,11 +56,16 @@ class ModFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
','
);
$this
->
_secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php
View file @
33fc28ff
...
...
@@ -24,30 +24,26 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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>
*/
class
SizeFunction
extends
FunctionNode
{
private
$_collectionPathExpression
;
public
function
getCollectionPathExpression
()
{
return
$this
->
_collectionPathExpression
;
}
public
function
setCollectionPathExpression
(
$collPathExpr
)
{
$this
->
_collectionPathExpression
=
$collPathExpr
;
}
public
$collectionPathExpression
;
/**
* @override
*/
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
$dqlAlias
=
$this
->
_collectionPathExpression
->
getIdentificationVariable
()
;
$dqlAlias
=
$this
->
collectionPathExpression
->
identificationVariable
;
$qComp
=
$sqlWalker
->
getQueryComponent
(
$dqlAlias
);
$parts
=
$this
->
_collectionPathExpression
->
getParts
()
;
$parts
=
$this
->
collectionPathExpression
->
parts
;
$assoc
=
$qComp
[
'metadata'
]
->
associationMappings
[
$parts
[
0
]];
...
...
@@ -80,9 +76,12 @@ class SizeFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_collectionPathExpression
=
$parser
->
CollectionValuedPathExpression
();
$this
->
collectionPathExpression
=
$parser
->
CollectionValuedPathExpression
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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>
*/
class
SqrtFunction
extends
FunctionNode
{
private
$_simpleArithmeticExpression
;
public
function
getSimpleArithmeticExpression
()
{
return
$this
->
_simpleArithmeticExpression
;
}
public
$simpleArithmeticExpression
;
/**
* @override
...
...
@@ -26,7 +42,7 @@ class SqrtFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//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
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
simpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,28 +24,19 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
private
$_stringPrimary
;
private
$_firstSimpleArithmeticExpression
;
private
$_secondSimpleArithmeticExpression
;
public
function
geStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
function
getSecondSimpleArithmeticExpression
()
{
return
$this
->
_secondSimpleArithmeticExpression
;
}
public
function
getFirstSimpleArithmeticExpression
()
{
return
$this
->
_firstSimpleArithmeticExpression
;
}
public
$stringPrimary
;
public
$firstSimpleArithmeticExpression
;
public
$secondSimpleArithmeticExpression
;
/**
* @override
...
...
@@ -38,14 +44,13 @@ class SubstringFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//TODO: Use platform to get SQL
$sql
=
'SUBSTRING('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_
stringPrimary
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_
firstSimpleArithmeticExpression
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
_
secondSimpleArithmeticExpression
)
return
'SUBSTRING('
.
$sqlWalker
->
walkStringPrimary
(
$this
->
stringPrimary
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
firstSimpleArithmeticExpression
)
.
', '
.
$sqlWalker
->
walkSimpleArithmeticExpression
(
$this
->
secondSimpleArithmeticExpression
)
.
')'
;
return
$sql
;
}
/**
...
...
@@ -54,14 +59,18 @@ class SubstringFunction extends FunctionNode
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
','
);
$this
->
_firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
firstSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
','
);
$this
->
_secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$this
->
secondSimpleArithmeticExpression
=
$parser
->
SimpleArithmeticExpression
();
$parser
->
match
(
')'
);
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -11,60 +26,21 @@ use Doctrine\ORM\Query\Lexer;
/**
* "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
{
private
$_leading
;
private
$_trailing
;
private
$_both
;
private
$_trimChar
;
private
$_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
;
}
public
$leading
;
public
$trailing
;
public
$both
;
public
$trimChar
;
public
$stringPrimary
;
/**
* @override
...
...
@@ -72,13 +48,20 @@ class TrimFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
$sql
=
'TRIM('
;
if
(
$this
->
_leading
)
$sql
.=
'LEADING '
;
else
if
(
$this
->
_trailing
)
$sql
.=
'TRAILING '
;
else
if
(
$this
->
_both
)
$sql
.=
'BOTH '
;
if
(
$this
->
_trimChar
)
$sql
.=
$sqlWalker
->
getConnection
()
->
quote
(
$this
->
_trimChar
)
.
' '
;
$sql
.=
'FROM '
.
$sqlWalker
->
walkStringPrimary
(
$this
->
_stringPrimary
);
$sql
.=
')'
;
return
$sql
;
if
(
$this
->
leading
)
{
$sql
.=
'LEADING '
;
}
else
if
(
$this
->
trailing
)
{
$sql
.=
'TRAILING '
;
}
else
if
(
$this
->
both
)
{
$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
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
if
(
strcasecmp
(
'leading'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
leading
=
true
;
$this
->
leading
=
true
;
}
else
if
(
strcasecmp
(
'trailing'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
trailing
=
true
;
$this
->
trailing
=
true
;
}
else
if
(
strcasecmp
(
'both'
,
$lexer
->
lookahead
[
'value'
])
===
0
)
{
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$this
->
_
both
=
true
;
$this
->
both
=
true
;
}
if
(
$lexer
->
isNextToken
(
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
);
}
$this
->
_
stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
}
...
...
lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,16 +24,17 @@ namespace Doctrine\ORM\Query\AST\Functions;
/**
* "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
{
private
$_stringPrimary
;
public
function
getStringPrimary
()
{
return
$this
->
_stringPrimary
;
}
public
$stringPrimary
;
/**
* @override
...
...
@@ -26,7 +42,7 @@ class UpperFunction extends FunctionNode
public
function
getSql
(
\Doctrine\ORM\Query\SqlWalker
$sqlWalker
)
{
//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
public
function
parse
(
\Doctrine\ORM\Query\Parser
$parser
)
{
$lexer
=
$parser
->
getLexer
();
$parser
->
match
(
$lexer
->
lookahead
[
'value'
]);
$parser
->
match
(
'('
);
$this
->
_stringPrimary
=
$parser
->
StringPrimary
();
$this
->
stringPrimary
=
$parser
->
StringPrimary
();
$parser
->
match
(
')'
);
}
}
...
...
lib/Doctrine/ORM/Query/AST/GroupByClause.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
groupByItems
=
array
();
p
ublic
$
groupByItems
=
array
();
public
function
__construct
(
array
$groupByItems
)
{
$this
->
_groupByItems
=
$groupByItems
;
}
public
function
getGroupByItems
()
{
return
$this
->
_groupByItems
;
$this
->
groupByItems
=
$groupByItems
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/HavingClause.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
conditionalExpression
;
p
ublic
$
conditionalExpression
;
public
function
__construct
(
$conditionalExpression
)
{
$this
->
_conditionalExpression
=
$conditionalExpression
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
$this
->
conditionalExpression
=
$conditionalExpression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php
View file @
33fc28ff
...
...
@@ -24,43 +24,25 @@ namespace Doctrine\ORM\Query\AST;
/**
* IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
protected
$_rangeVariableDeclaration
=
null
;
protected
$_indexBy
=
null
;
protected
$_joinVariableDeclarations
=
array
();
public
$rangeVariableDeclaration
=
null
;
public
$indexBy
=
null
;
public
$joinVariableDeclarations
=
array
();
public
function
__construct
(
$rangeVariableDecl
,
$indexBy
,
array
$joinVariableDecls
)
{
$this
->
_rangeVariableDeclaration
=
$rangeVariableDecl
;
$this
->
_indexBy
=
$indexBy
;
$this
->
_joinVariableDeclarations
=
$joinVariableDecls
;
}
/* Getters */
public
function
getRangeVariableDeclaration
()
{
return
$this
->
_rangeVariableDeclaration
;
}
public
function
getIndexBy
()
{
return
$this
->
_indexBy
;
}
public
function
getJoinVariableDeclarations
()
{
return
$this
->
_joinVariableDeclarations
;
$this
->
rangeVariableDeclaration
=
$rangeVariableDecl
;
$this
->
indexBy
=
$indexBy
;
$this
->
joinVariableDeclarations
=
$joinVariableDecls
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/InExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,53 +24,24 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_pathExpression
;
p
rivate
$_not
=
false
;
p
rivate
$_
literals
=
array
();
p
rivate
$_
subselect
;
p
ublic
$not
;
p
ublic
$pathExpression
;
p
ublic
$
literals
=
array
();
p
ublic
$
subselect
;
public
function
__construct
(
$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
;
$this
->
pathExpression
=
$pathExpression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/IndexBy.php
View file @
33fc28ff
...
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* IndexBy ::= "INDEX" "BY" SimpleStateFieldPathExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rotected
$_
simpleStateFieldPathExpression
=
null
;
p
ublic
$
simpleStateFieldPathExpression
=
null
;
public
function
__construct
(
$simpleStateFieldPathExpression
)
{
$this
->
_simpleStateFieldPathExpression
=
$simpleStateFieldPathExpression
;
}
/* Getters */
public
function
getSimpleStateFieldPathExpression
()
{
return
$this
->
_simpleStateFieldPathExpression
;
$this
->
simpleStateFieldPathExpression
=
$simpleStateFieldPathExpression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/InputParameter.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,13 +24,18 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_isNamed
;
private
$_position
;
private
$_name
;
public
$isNamed
;
public
$name
;
public
function
__construct
(
$value
)
{
...
...
@@ -24,32 +44,8 @@ class InputParameter extends Node
}
$param
=
substr
(
$value
,
1
);
$this
->
_isNamed
=
!
is_numeric
(
$param
);
if
(
$this
->
_isNamed
)
{
$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
;
$this
->
isNamed
=
!
is_numeric
(
$param
);
$this
->
name
=
$param
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Join.php
View file @
33fc28ff
...
...
@@ -25,11 +25,13 @@ namespace Doctrine\ORM\Query\AST;
* Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
* ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
...
...
@@ -39,55 +41,17 @@ class Join extends Node
const
JOIN_WHERE_ON
=
1
;
const
JOIN_WHERE_WITH
=
2
;
p
rotected
$_
joinType
=
self
::
JOIN_TYPE_INNER
;
p
rotected
$_
joinAssociationPathExpression
=
null
;
p
rotected
$_
aliasIdentificationVariable
=
null
;
p
rotected
$_
whereType
=
self
::
JOIN_WHERE_WITH
;
p
rotected
$_
conditionalExpression
=
null
;
p
ublic
$
joinType
=
self
::
JOIN_TYPE_INNER
;
p
ublic
$
joinAssociationPathExpression
=
null
;
p
ublic
$
aliasIdentificationVariable
=
null
;
p
ublic
$
whereType
=
self
::
JOIN_WHERE_WITH
;
p
ublic
$
conditionalExpression
=
null
;
public
function
__construct
(
$joinType
,
$joinAssocPathExpr
,
$aliasIdentVar
)
{
$this
->
_joinType
=
$joinType
;
$this
->
_joinAssociationPathExpression
=
$joinAssocPathExpr
;
$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
;
$this
->
joinType
=
$joinType
;
$this
->
joinAssociationPathExpression
=
$joinAssocPathExpr
;
$this
->
aliasIdentificationVariable
=
$aliasIdentVar
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php
View file @
33fc28ff
<?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
;
/**
* 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 Roman Borschel
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class
JoinAssociationPathExpression
extends
Node
{
private
$_identificationVariable
;
private
$_assocField
;
public
function
__construct
(
$identificationVariable
,
$assocField
)
{
$this
->
_identificationVariable
=
$identificationVariable
;
$this
->
_assocField
=
$assocField
;
}
public
function
getIdentificationVariable
()
{
return
$this
->
_identificationVariable
;
}
public
$identificationVariable
;
public
$associationField
;
public
function
getAssociationField
(
)
public
function
__construct
(
$identificationVariable
,
$associationField
)
{
return
$this
->
_assocField
;
$this
->
identificationVariable
=
$identificationVariable
;
$this
->
associationField
=
$associationField
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php
View file @
33fc28ff
...
...
@@ -24,32 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
* JoinVariableDeclaration ::= Join [IndexBy]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
p
rotected
$_
join
=
null
;
p
rotected
$_
indexBy
=
null
;
p
ublic
$
join
=
null
;
p
ublic
$
indexBy
=
null
;
public
function
__construct
(
$join
,
$indexBy
)
{
$this
->
_join
=
$join
;
$this
->
_indexBy
=
$indexBy
;
}
/* Getters */
public
function
getJoin
()
{
return
$this
->
_join
;
}
public
function
getIndexBy
()
{
return
$this
->
_indexBy
;
$this
->
join
=
$join
;
$this
->
indexBy
=
$indexBy
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/LikeExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,41 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_stringExpr
;
private
$_isNot
;
private
$_stringPattern
;
private
$_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
$not
;
public
$stringExpression
;
public
$stringPattern
;
public
$escapeChar
;
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
)
...
...
lib/Doctrine/ORM/Query/AST/Node.php
View file @
33fc28ff
...
...
@@ -24,13 +24,13 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
...
...
lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,31 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_expression
;
p
rivate
$_not
;
p
ublic
$not
;
p
ublic
$expression
;
public
function
__construct
(
$expression
)
{
$this
->
_expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
setNot
(
$bool
)
{
$this
->
_not
=
$bool
;
}
public
function
isNot
()
{
return
$this
->
_not
;
$this
->
expression
=
$expression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/OrderByClause.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_
orderByItems
=
array
();
p
ublic
$
orderByItems
=
array
();
public
function
__construct
(
array
$orderByItems
)
{
$this
->
_orderByItems
=
$orderByItems
;
}
public
function
getOrderByItems
()
{
return
$this
->
_orderByItems
;
$this
->
orderByItems
=
$orderByItems
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/OrderByItem.php
View file @
33fc28ff
...
...
@@ -22,48 +22,34 @@
namespace
Doctrine\ORM\Query\AST
;
/**
* AST node for the following grammar rule:
*
* 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 Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
class
OrderByItem
extends
Node
{
private
$_expr
;
private
$_asc
;
private
$_desc
;
public
function
__construct
(
$expr
)
{
$this
->
_expr
=
$expr
;
}
public
$expression
;
public
$type
;
public
function
getExpression
(
)
public
function
__construct
(
$expression
)
{
return
$this
->
_expr
;
}
public
function
setAsc
(
$bool
)
{
$this
->
_asc
=
$bool
;
$this
->
expression
=
$expression
;
}
public
function
isAsc
()
{
return
$this
->
_asc
;
}
public
function
setDesc
(
$bool
)
{
$this
->
_desc
=
$bool
;
return
strtoupper
(
$this
->
type
)
==
'ASC'
;
}
public
function
isDesc
()
{
return
$this
->
_desc
;
return
strtoupper
(
$this
->
type
)
==
'DESC'
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/PathExpression.php
View file @
33fc28ff
<?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
;
/**
* AST node for the following path expressions:
*
* AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression
*
* SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression
*
* StateFieldPathExpression ::= SimpleStateFieldPathExpression | SimpleStateFieldAssociationPathExpression
*
* SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
*
* CollectionValuedPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* CollectionValuedAssociationField
*
* StateField ::= {EmbeddedClassStateField "."}* SimpleStateField
*
* SimpleStateFieldPathExpression ::= IdentificationVariable "." 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
* @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
{
...
...
@@ -30,54 +45,21 @@ class PathExpression extends Node
const
TYPE_SINGLE_VALUED_ASSOCIATION
=
4
;
const
TYPE_STATE_FIELD
=
8
;
p
rivate
$_
type
;
p
rivate
$_
expectedType
;
p
rivate
$_
identificationVariable
;
p
rivate
$_
parts
;
p
ublic
$
type
;
p
ublic
$
expectedType
;
p
ublic
$
identificationVariable
;
p
ublic
$
parts
;
public
function
__construct
(
$expectedType
,
$identificationVariable
,
array
$parts
)
{
$this
->
_expectedType
=
$expectedType
;
$this
->
_identificationVariable
=
$identificationVariable
;
$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
;
$this
->
expectedType
=
$expectedType
;
$this
->
identificationVariable
=
$identificationVariable
;
$this
->
parts
=
$parts
;
}
public
function
dispatch
(
$walker
)
{
switch
(
$this
->
_
type
)
{
switch
(
$this
->
type
)
{
case
self
::
TYPE_STATE_FIELD
:
return
$walker
->
walkStateFieldPathExpression
(
$this
);
case
self
::
TYPE_SINGLE_VALUED_ASSOCIATION
:
...
...
lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,18 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
private
$_all
;
private
$_any
;
private
$_some
;
private
$_subselect
;
public
$type
;
public
$subselect
;
public
function
__construct
(
$subselect
)
{
$this
->
_
subselect
=
$subselect
;
$this
->
subselect
=
$subselect
;
}
public
function
getSubselect
()
...
...
@@ -30,32 +49,17 @@ class QuantifiedExpression extends Node
public
function
isAll
()
{
return
$this
->
_all
;
return
strtoupper
(
$this
->
type
)
==
'ALL'
;
}
public
function
isAny
()
{
return
$this
->
_any
;
return
strtoupper
(
$this
->
type
)
==
'ANY'
;
}
public
function
isSome
()
{
return
$this
->
_some
;
}
public
function
setAll
(
$bool
)
{
$this
->
_all
=
$bool
;
}
public
function
setAny
(
$bool
)
{
$this
->
_any
=
$bool
;
}
public
function
setSome
(
$bool
)
{
$this
->
_some
=
$bool
;
return
strtoupper
(
$this
->
type
)
==
'SOME'
;
}
/**
...
...
lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php
View file @
33fc28ff
...
...
@@ -24,39 +24,25 @@ namespace Doctrine\ORM\Query\AST;
/**
* RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rivate
$_
classMetadata
;
p
rivate
$_
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
ublic
$
classMetadata
;
p
ublic
$
abstractSchemaName
;
p
ublic
$
aliasIdentificationVariable
;
public
function
__construct
(
$classMetadata
,
$aliasIdentificationVar
)
{
$this
->
_classMetadata
=
$classMetadata
;
$this
->
_abstractSchemaName
=
$classMetadata
->
name
;
$this
->
_aliasIdentificationVariable
=
$aliasIdentificationVar
;
}
/* Getters */
public
function
getAbstractSchemaName
()
{
return
$this
->
_abstractSchemaName
;
}
public
function
getAliasIdentificationVariable
()
{
return
$this
->
_aliasIdentificationVariable
;
}
public
function
getClassMetadata
()
{
return
$this
->
_classMetadata
;
$this
->
classMetadata
=
$classMetadata
;
$this
->
abstractSchemaName
=
$classMetadata
->
name
;
$this
->
aliasIdentificationVariable
=
$aliasIdentificationVar
;
}
public
function
dispatch
(
$walker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectClause.php
View file @
33fc28ff
...
...
@@ -24,50 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
* SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
protected
$_isDistinct
;
protected
$_selectExpressions
=
array
();
public
$isDistinct
;
public
$selectExpressions
=
array
();
public
function
__construct
(
array
$selectExpressions
,
$isDistinct
)
{
$this
->
_isDistinct
=
$isDistinct
;
$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
;
$this
->
isDistinct
=
$isDistinct
;
$this
->
selectExpressions
=
$selectExpressions
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectExpression.php
View file @
33fc28ff
...
...
@@ -25,32 +25,23 @@ namespace Doctrine\ORM\Query\AST;
* SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression |
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
p
rotected
$_
expression
;
p
rotected
$_
fieldIdentificationVariable
;
p
ublic
$
expression
;
p
ublic
$
fieldIdentificationVariable
;
public
function
__construct
(
$expression
,
$fieldIdentificationVariable
)
{
$this
->
_expression
=
$expression
;
$this
->
_fieldIdentificationVariable
=
$fieldIdentificationVariable
;
}
/* Getters */
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
getFieldIdentificationVariable
()
{
return
$this
->
_fieldIdentificationVariable
;
$this
->
expression
=
$expression
;
$this
->
fieldIdentificationVariable
=
$fieldIdentificationVariable
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SelectStatement.php
View file @
33fc28ff
...
...
@@ -24,60 +24,26 @@ namespace Doctrine\ORM\Query\AST;
/**
* SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://www.phpdoctrine
.org
* @link
www.doctrine-project
.org
* @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
{
protected
$_selectClause
;
protected
$_fromClause
;
protected
$_whereClause
;
protected
$_groupByClause
;
protected
$_havingClause
;
protected
$_orderByClause
;
public
function
__construct
(
$selectClause
,
$fromClause
,
$whereClause
,
$groupByClause
,
$havingClause
,
$orderByClause
)
{
$this
->
_selectClause
=
$selectClause
;
$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
$selectClause
;
public
$fromClause
;
public
$whereClause
;
public
$groupByClause
;
public
$havingClause
;
public
$orderByClause
;
public
function
__construct
(
$selectClause
,
$fromClause
)
{
$this
->
selectClause
=
$selectClause
;
$this
->
fromClause
=
$fromClause
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
...
...
@@ -9,20 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* 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
{
p
rivate
$_terms
;
p
ublic
$arithmeticTerms
=
array
()
;
public
function
__construct
(
array
$arithmeticTerms
)
{
$this
->
_terms
=
$arithmeticTerms
;
}
public
function
getArithmeticTerms
()
{
return
$this
->
_terms
;
$this
->
arithmeticTerms
=
$arithmeticTerms
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php
View file @
33fc28ff
...
...
@@ -24,36 +24,23 @@ namespace Doctrine\ORM\Query\AST;
/**
* SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
private
$_isDistinct
=
false
;
private
$_simpleSelectExpression
;
public
function
__construct
(
$simpleSelectExpression
)
{
$this
->
_simpleSelectExpression
=
$simpleSelectExpression
;
}
/* Getters */
public
function
isDistinct
()
{
return
$this
->
_isDistinct
;
}
public
function
setDistinct
(
$bool
)
{
$this
->
_isDistinct
=
$bool
;
}
public
$isDistinct
=
false
;
public
$simpleSelectExpression
;
public
function
getSimpleSelectExpression
(
)
public
function
__construct
(
$simpleSelectExpression
,
$isDistinct
)
{
return
$this
->
_simpleSelectExpression
;
$this
->
simpleSelectExpression
=
$simpleSelectExpression
;
$this
->
isDistinct
=
$isDistinct
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php
View file @
33fc28ff
...
...
@@ -25,35 +25,22 @@ namespace Doctrine\ORM\Query\AST;
* SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable
* | (AggregateExpression [["AS"] FieldAliasIdentificationVariable])
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rivate
$_
expression
;
p
rivate
$_
fieldIdentificationVariable
;
p
ublic
$
expression
;
p
ublic
$
fieldIdentificationVariable
;
public
function
__construct
(
$expression
)
{
$this
->
_expression
=
$expression
;
}
public
function
getExpression
()
{
return
$this
->
_expression
;
}
public
function
getFieldIdentificationVariable
()
{
return
$this
->
_fieldIdentificationVariable
;
}
public
function
setFieldIdentificationVariable
(
$fieldAlias
)
{
$this
->
_fieldIdentificationVariable
=
$fieldAlias
;
$this
->
expression
=
$expression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/Subselect.php
View file @
33fc28ff
...
...
@@ -24,76 +24,27 @@ namespace Doctrine\ORM\Query\AST;
/**
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rivate
$_
simpleSelectClause
;
p
rivate
$_
subselectFromClause
;
p
rivate
$_
whereClause
;
p
rivate
$_
groupByClause
;
p
rivate
$_
havingClause
;
p
rivate
$_
orderByClause
;
p
ublic
$
simpleSelectClause
;
p
ublic
$
subselectFromClause
;
p
ublic
$
whereClause
;
p
ublic
$
groupByClause
;
p
ublic
$
havingClause
;
p
ublic
$
orderByClause
;
public
function
__construct
(
$simpleSelectClause
,
$subselectFromClause
)
{
$this
->
_simpleSelectClause
=
$simpleSelectClause
;
$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
;
$this
->
simpleSelectClause
=
$simpleSelectClause
;
$this
->
subselectFromClause
=
$subselectFromClause
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/SubselectFromClause.php
View file @
33fc28ff
...
...
@@ -24,25 +24,21 @@ namespace Doctrine\ORM\Query\AST;
/**
* SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rivate
$_
identificationVariableDeclarations
=
array
();
p
ublic
$
identificationVariableDeclarations
=
array
();
public
function
__construct
(
array
$identificationVariableDeclarations
)
{
$this
->
_identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
/* Getters */
public
function
getSubselectIdentificationVariableDeclarations
()
{
return
$this
->
_identificationVariableDeclarations
;
$this
->
identificationVariableDeclarations
=
$identificationVariableDeclarations
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateClause.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
/**
* 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
{
p
rivate
$_
abstractSchemaName
;
p
rivate
$_
aliasIdentificationVariable
;
p
rivate
$_
updateItems
=
array
();
p
ublic
$
abstractSchemaName
;
p
ublic
$
aliasIdentificationVariable
;
p
ublic
$
updateItems
=
array
();
public
function
__construct
(
$abstractSchemaName
,
array
$updateItems
)
{
$this
->
_abstractSchemaName
=
$abstractSchemaName
;
$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
;
$this
->
abstractSchemaName
=
$abstractSchemaName
;
$this
->
updateItems
=
$updateItems
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateItem.php
View file @
33fc28ff
...
...
@@ -26,39 +26,24 @@ namespace Doctrine\ORM\Query\AST;
* NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary |
* 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
* @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
{
p
rivate
$_
identificationVariable
;
p
rivate
$_
field
;
p
rivate
$_
newValue
;
p
ublic
$
identificationVariable
;
p
ublic
$
field
;
p
ublic
$
newValue
;
public
function
__construct
(
$field
,
$newValue
)
{
$this
->
_field
=
$field
;
$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
;
$this
->
field
=
$field
;
$this
->
newValue
=
$newValue
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/UpdateStatement.php
View file @
33fc28ff
...
...
@@ -24,35 +24,22 @@ namespace Doctrine\ORM\Query\AST;
/**
* UpdateStatement = UpdateClause [WhereClause]
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
p
rivate
$_
updateClause
;
p
rivate
$_
whereClause
;
p
ublic
$
updateClause
;
p
ublic
$
whereClause
;
public
function
__construct
(
$updateClause
)
{
$this
->
_updateClause
=
$updateClause
;
}
public
function
setWhereClause
(
$whereClause
)
{
$this
->
_whereClause
=
$whereClause
;
}
public
function
getUpdateClause
()
{
return
$this
->
_updateClause
;
}
public
function
getWhereClause
()
{
return
$this
->
_whereClause
;
$this
->
updateClause
=
$updateClause
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/AST/WhereClause.php
View file @
33fc28ff
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* $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
;
/**
*
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
{
p
rivate
$_
conditionalExpression
;
p
ublic
$
conditionalExpression
;
public
function
__construct
(
$conditionalExpression
)
{
$this
->
_conditionalExpression
=
$conditionalExpression
;
}
public
function
getConditionalExpression
()
{
return
$this
->
_conditionalExpression
;
$this
->
conditionalExpression
=
$conditionalExpression
;
}
public
function
dispatch
(
$sqlWalker
)
...
...
lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php
View file @
33fc28ff
...
...
@@ -53,9 +53,9 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$conn
=
$em
->
getConnection
();
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$AST
->
getDeleteClause
()
->
getAbstractSchemaName
()
$AST
->
deleteClause
->
abstractSchemaName
);
$primaryDqlAlias
=
$AST
->
getDeleteClause
()
->
getAliasIdentificationVariable
()
;
$primaryDqlAlias
=
$AST
->
deleteClause
->
aliasIdentificationVariable
;
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
...
...
@@ -71,8 +71,8 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
// Append WHERE clause, if there is one.
if
(
$AST
->
getWhereClause
()
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
getWhereClause
()
);
if
(
$AST
->
whereClause
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
whereClause
);
}
// 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
{
$em
=
$sqlWalker
->
getEntityManager
();
$conn
=
$em
->
getConnection
();
$updateClause
=
$AST
->
updateClause
;
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$AST
->
getUpdateClause
()
->
getAbstractSchemaName
()
);
$primaryClass
=
$sqlWalker
->
getEntityManager
()
->
getClassMetadata
(
$updateClause
->
abstractSchemaName
);
$rootClass
=
$em
->
getClassMetadata
(
$primaryClass
->
rootEntityName
);
$updateItems
=
$
AST
->
getUpdateClause
()
->
getUpdateItems
()
;
$updateItems
=
$
updateClause
->
updateItems
;
$tempTable
=
$rootClass
->
getTemporaryIdTableName
();
$idColumnNames
=
$rootClass
->
getIdentifierColumnNames
();
...
...
@@ -68,8 +67,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
// 1. Create an INSERT INTO temptable ... SELECT identifiers WHERE $AST->getWhereClause()
$this
->
_insertSql
=
'INSERT INTO '
.
$tempTable
.
' ('
.
$idColumnList
.
')'
.
' SELECT t0.'
.
implode
(
', t0.'
,
$idColumnNames
);
$sqlWalker
->
setSqlTableAlias
(
$primaryClass
->
primaryTable
[
'name'
]
.
$
AST
->
getUpdateClause
()
->
getAliasIdentificationVariable
()
,
't0'
);
$rangeDecl
=
new
AST\RangeVariableDeclaration
(
$primaryClass
,
$
AST
->
getUpdateClause
()
->
getAliasIdentificationVariable
()
);
$sqlWalker
->
setSqlTableAlias
(
$primaryClass
->
primaryTable
[
'name'
]
.
$
updateClause
->
aliasIdentificationVariable
,
't0'
);
$rangeDecl
=
new
AST\RangeVariableDeclaration
(
$primaryClass
,
$
updateClause
->
aliasIdentificationVariable
);
$fromClause
=
new
AST\FromClause
(
array
(
new
AST\IdentificationVariableDeclaration
(
$rangeDecl
,
null
,
array
())));
$this
->
_insertSql
.=
$sqlWalker
->
walkFromClause
(
$fromClause
);
...
...
@@ -79,6 +78,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
// 3. Create and store UPDATE statements
$classNames
=
array_merge
(
$primaryClass
->
parentClasses
,
array
(
$primaryClass
->
name
),
$primaryClass
->
subClasses
);
$i
=
-
1
;
foreach
(
array_reverse
(
$classNames
)
as
$className
)
{
$affected
=
false
;
$class
=
$em
->
getClassMetadata
(
$className
);
...
...
@@ -86,19 +86,22 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
$updateSql
=
'UPDATE '
.
$conn
->
quoteIdentifier
(
$tableName
)
.
' SET '
;
foreach
(
$updateItems
as
$updateItem
)
{
$field
=
$updateItem
->
getField
()
;
$field
=
$updateItem
->
field
;
if
(
isset
(
$class
->
fieldMappings
[
$field
])
&&
!
isset
(
$class
->
fieldMappings
[
$field
][
'inherited'
]))
{
$newValue
=
$updateItem
->
getNewValue
();
$newValue
=
$updateItem
->
newValue
;
if
(
!
$affected
)
{
$affected
=
true
;
++
$i
;
}
else
{
$updateSql
.=
', '
;
}
$updateSql
.=
$sqlWalker
->
walkUpdateItem
(
$updateItem
);
//FIXME: parameters can be more deeply nested. traverse the tree.
if
(
$newValue
instanceof
AST\InputParameter
)
{
$paramKey
=
$newValue
->
isNamed
()
?
$newValue
->
getName
()
:
$newValue
->
getPosition
()
;
$paramKey
=
$newValue
->
name
;
$this
->
_sqlParameters
[
$i
][]
=
$sqlWalker
->
getQuery
()
->
getParameter
(
$paramKey
);
++
$this
->
_numParametersInUpdateClause
;
}
...
...
@@ -111,8 +114,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
}
// Append WHERE clause to insertSql, if there is one.
if
(
$AST
->
getWhereClause
()
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
getWhereClause
()
);
if
(
$AST
->
whereClause
)
{
$this
->
_insertSql
.=
$sqlWalker
->
walkWhereClause
(
$AST
->
whereClause
);
}
// 4. Store DDL for temporary identifier table.
...
...
lib/Doctrine/ORM/Query/Parser.php
View file @
33fc28ff
...
...
@@ -30,13 +30,14 @@ use Doctrine\Common\DoctrineException,
* 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.
*
* @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
* @link
http://
www.doctrine-project.org
* @link www.doctrine-project.org
* @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
{
...
...
@@ -482,16 +483,16 @@ class Parser
*/
private
function
_validatePathExpression
(
AST\PathExpression
$pathExpression
,
$nestingLevel
=
null
,
$token
=
null
)
{
$ident
ificationVariable
=
$pathExpression
->
getIdentificationVariable
()
;
$ident
Variable
=
$pathExpression
->
identificationVariable
;
$nestingLevel
=
(
$nestingLevel
!==
null
)
?:
$this
->
_nestingLevel
;
$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
;
foreach
(
$pathExpression
->
getParts
()
as
$field
)
{
foreach
(
$pathExpression
->
parts
as
$field
)
{
// Check if it is not in a state field
if
(
$stateField
!==
null
)
{
$this
->
semanticalError
(
...
...
@@ -535,7 +536,7 @@ class Parser
}
// Validate if PathExpression is one of the expected types
$expectedType
=
$pathExpression
->
getExpectedType
()
;
$expectedType
=
$pathExpression
->
expectedType
;
if
(
!
(
$expectedType
&
$expressionType
))
{
// We need to recognize which was expected type(s)
...
...
@@ -569,7 +570,7 @@ class Parser
}
// We need to force the type in PathExpression
$pathExpression
->
setType
(
$expressionType
)
;
$pathExpression
->
type
=
$expressionType
;
return
$expressionType
;
}
...
...
@@ -578,33 +579,33 @@ class Parser
* Validates that the given <tt>IdentificationVariable</tt> is a semantically correct.
* It must exist in query components list.
*
* @param string $idVariable
* @param string $id
ent
Variable
* @param integer $nestingLevel
* @param array $token
* @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
;
$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
)
.
']'
;
$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
if
(
$this
->
_queryComponents
[
$idVariable
][
'nestingLevel'
]
>
$nestingLevel
)
{
if
(
$this
->
_queryComponents
[
$id
ent
Variable
][
'nestingLevel'
]
>
$nestingLevel
)
{
$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
);
}
return
$this
->
_queryComponents
[
$idVariable
];
return
$this
->
_queryComponents
[
$id
ent
Variable
];
}
...
...
@@ -647,27 +648,24 @@ class Parser
// since we do not have any IdentificationVariable yet
$this
->
_beginDeferredPathExpressionStack
();
$selectClause
=
$this
->
SelectClause
();
$fromClause
=
$this
->
FromClause
();
$selectStatement
=
new
AST\SelectStatement
(
$this
->
SelectClause
(),
$this
->
FromClause
());
// Activate semantical checks after this point. Process all deferred checks in pipeline
$this
->
_processDeferredPathExpressionStack
();
$whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
$
selectStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
;
$groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
$
selectStatement
->
groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
?
$this
->
GroupByClause
()
:
null
;
$havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
$
selectStatement
->
havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
?
$this
->
HavingClause
()
:
null
;
$orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
$
selectStatement
->
orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
?
$this
->
OrderByClause
()
:
null
;
return
new
AST\SelectStatement
(
$selectClause
,
$fromClause
,
$whereClause
,
$groupByClause
,
$havingClause
,
$orderByClause
);
return
$selectStatement
;
}
/**
...
...
@@ -678,9 +676,8 @@ class Parser
public
function
UpdateStatement
()
{
$updateStatement
=
new
AST\UpdateStatement
(
$this
->
UpdateClause
());
$updateStatement
->
setWhereClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
);
$updateStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
;
return
$updateStatement
;
}
...
...
@@ -693,9 +690,8 @@ class Parser
public
function
DeleteStatement
()
{
$deleteStatement
=
new
AST\DeleteStatement
(
$this
->
DeleteClause
());
$deleteStatement
->
setWhereClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
);
$deleteStatement
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
;
return
$deleteStatement
;
}
...
...
@@ -758,22 +754,22 @@ class Parser
public
function
JoinAssociationPathExpression
()
{
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
$this
->
match
(
'.'
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
$field
=
$this
->
_lexer
->
token
[
'value'
];
// 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)
$class
=
$this
->
_queryComponents
[
$ident
ification
Variable
][
'metadata'
];
$class
=
$this
->
_queryComponents
[
$identVariable
][
'metadata'
];
if
(
!
isset
(
$class
->
associationMappings
[
$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
public
function
PathExpression
(
$expectedType
)
{
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
$parts
=
array
();
do
{
...
...
@@ -799,7 +795,7 @@ class Parser
}
while
(
$this
->
_lexer
->
isNextToken
(
'.'
));
// 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
if
(
!
empty
(
$this
->
_deferredPathExpressionStacks
))
{
...
...
@@ -884,7 +880,7 @@ class Parser
public
function
SimpleStateFieldPathExpression
()
{
$pathExpression
=
$this
->
PathExpression
(
AST\PathExpression
::
TYPE_STATE_FIELD
);
$parts
=
$pathExpression
->
getParts
()
;
$parts
=
$pathExpression
->
parts
;
if
(
count
(
$parts
)
>
1
)
{
$this
->
semanticalError
(
...
...
@@ -932,18 +928,15 @@ class Parser
*/
public
function
SimpleSelectClause
()
{
$
d
istinct
=
false
;
$
isD
istinct
=
false
;
$this
->
match
(
Lexer
::
T_SELECT
);
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DISTINCT
))
{
$this
->
match
(
Lexer
::
T_DISTINCT
);
$
d
istinct
=
true
;
$
isD
istinct
=
true
;
}
$simpleSelectClause
=
new
AST\SimpleSelectClause
(
$this
->
SimpleSelectExpression
());
$simpleSelectClause
->
setDistinct
(
$distinct
);
return
$simpleSelectClause
;
return
new
AST\SimpleSelectClause
(
$this
->
SimpleSelectExpression
(),
$isDistinct
);
}
/**
...
...
@@ -992,7 +985,7 @@ class Parser
}
$updateClause
=
new
AST\UpdateClause
(
$abstractSchemaName
,
$updateItems
);
$updateClause
->
setAliasIdentificationVariable
(
$aliasIdentificationVariable
)
;
$updateClause
->
aliasIdentificationVariable
=
$aliasIdentificationVariable
;
return
$updateClause
;
}
...
...
@@ -1022,11 +1015,11 @@ class Parser
$token
=
$this
->
_lexer
->
lookahead
;
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
}
else
{
$aliasIdentificationVariable
=
$deleteClause
->
getAbstractSchemaName
()
;
$aliasIdentificationVariable
=
$deleteClause
->
abstractSchemaName
;
}
$deleteClause
->
setAliasIdentificationVariable
(
$aliasIdentificationVariable
)
;
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
getAbstractSchemaName
()
);
$deleteClause
->
aliasIdentificationVariable
=
$aliasIdentificationVariable
;
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
abstractSchemaName
);
// Building queryComponent
$queryComponent
=
array
(
...
...
@@ -1156,24 +1149,22 @@ class Parser
$this
->
_nestingLevel
++
;
$this
->
_beginDeferredPathExpressionStack
();
$subselect
=
new
AST\Subselect
(
$this
->
SimpleSelectClause
(),
$this
->
SubselectFromClause
());
$this
->
_processDeferredPathExpressionStack
();
$subselect
->
setWhereClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
);
$subselect
->
whereClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_WHERE
)
?
$this
->
WhereClause
()
:
null
;
$subselect
->
setGroupByClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
?
$this
->
GroupByClause
()
:
null
);
$subselect
->
groupByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_GROUP
)
?
$this
->
GroupByClause
()
:
null
;
$subselect
->
setHavingClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
?
$this
->
HavingClause
()
:
null
);
$subselect
->
havingClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_HAVING
)
?
$this
->
HavingClause
()
:
null
;
$subselect
->
setOrderByClause
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
?
$this
->
OrderByClause
()
:
null
);
$subselect
->
orderByClause
=
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ORDER
)
?
$this
->
OrderByClause
()
:
null
;
// Decrease query nesting level
$this
->
_nestingLevel
--
;
...
...
@@ -1190,10 +1181,10 @@ class Parser
public
function
UpdateItem
()
{
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
// Validate if IdentificationVariable is defined
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$ident
ification
Variable
,
null
,
$token
);
$queryComponent
=
$this
->
_validateIdentificationVariable
(
$identVariable
,
null
,
$token
);
$this
->
match
(
'.'
);
$this
->
match
(
Lexer
::
T_IDENTIFIER
);
...
...
@@ -1213,7 +1204,7 @@ class Parser
$newValue
=
$this
->
NewValue
();
$updateItem
=
new
AST\UpdateItem
(
$field
,
$newValue
);
$updateItem
->
setIdentificationVariable
(
$identificationVariable
)
;
$updateItem
->
identificationVariable
=
$identVariable
;
return
$updateItem
;
}
...
...
@@ -1230,12 +1221,12 @@ class Parser
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
$token
=
$this
->
_lexer
->
lookahead
;
$ident
ification
Variable
=
$this
->
IdentificationVariable
();
$identVariable
=
$this
->
IdentificationVariable
();
// 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
();
...
...
@@ -1251,15 +1242,17 @@ class Parser
*/
public
function
OrderByItem
()
{
$type
=
'ASC'
;
// We need to check if we are in a ResultVariable or StateFieldPathExpression
$glimpse
=
$this
->
_lexer
->
glimpse
();
if
(
$glimpse
[
'value'
]
!=
'.'
)
{
$token
=
$this
->
_lexer
->
lookahead
;
$
expr
=
$this
->
ResultVariable
();
$
resultVariable
=
$this
->
ResultVariable
();
// 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.
// ResultVariable exists in queryComponents, check nesting level
...
...
@@ -1276,17 +1269,12 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ASC
))
{
$this
->
match
(
Lexer
::
T_ASC
);
$item
->
setAsc
(
true
);
return
$item
;
}
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DESC
))
{
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_DESC
))
{
$this
->
match
(
Lexer
::
T_DESC
);
$item
->
setDesc
(
true
);
return
$item
;
$type
=
'DESC'
;
}
$item
->
setAsc
(
true
)
;
$item
->
type
=
$type
;
return
$item
;
}
...
...
@@ -1350,10 +1338,10 @@ class Parser
$peek
=
$this
->
_lexer
->
glimpse
();
if
(
$peek
[
'value'
]
==
'.'
)
{
$subselectIdVarDecl
=
new
AST\SubselectIdentificationVariableDeclaration
;
$subselectIdVarDecl
->
setAssociationPathExpression
(
$this
->
AssociationPathExpression
()
);
$subselectIdVarDecl
=
new
AST\SubselectIdentificationVariableDeclaration
()
;
$subselectIdVarDecl
->
associationPathExpression
=
$this
->
AssociationPathExpression
(
);
$this
->
match
(
Lexer
::
T_AS
);
$subselectIdVarDecl
->
setAliasIdentificationVariable
(
$this
->
AliasIdentificationVariable
()
);
$subselectIdVarDecl
->
aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
(
);
return
$subselectIdVarDecl
;
}
...
...
@@ -1445,8 +1433,8 @@ class Parser
$aliasIdentificationVariable
=
$this
->
AliasIdentificationVariable
();
// Verify that the association exists.
$parentClass
=
$this
->
_queryComponents
[
$joinPathExpression
->
getIdentificationVariable
()
][
'metadata'
];
$assocField
=
$joinPathExpression
->
getAssociationField
()
;
$parentClass
=
$this
->
_queryComponents
[
$joinPathExpression
->
identificationVariable
][
'metadata'
];
$assocField
=
$joinPathExpression
->
associationField
;
if
(
!
$parentClass
->
hasAssociation
(
$assocField
))
{
$this
->
semanticalError
(
...
...
@@ -1459,7 +1447,7 @@ class Parser
// Building queryComponent
$joinQueryComponent
=
array
(
'metadata'
=>
$this
->
_em
->
getClassMetadata
(
$targetClassName
),
'parent'
=>
$joinPathExpression
->
getIdentificationVariable
()
,
'parent'
=>
$joinPathExpression
->
identificationVariable
,
'relation'
=>
$parentClass
->
getAssociationMapping
(
$assocField
),
'map'
=>
null
,
'nestingLevel'
=>
$this
->
_nestingLevel
,
...
...
@@ -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
->
match
(
Lexer
::
T_ON
);
$join
->
setWhereType
(
AST\Join
::
JOIN_WHERE_ON
)
;
$join
->
whereType
=
AST\Join
::
JOIN_WHERE_ON
;
}
else
{
$this
->
match
(
Lexer
::
T_WITH
);
}
$join
->
setConditionalExpression
(
$this
->
ConditionalExpression
()
);
$join
->
conditionalExpression
=
$this
->
ConditionalExpression
(
);
}
return
$join
;
...
...
@@ -1497,8 +1485,8 @@ class Parser
$pathExp
=
$this
->
SimpleStateFieldPathExpression
();
// Add the INDEX BY info to the query component
$parts
=
$pathExp
->
getParts
()
;
$this
->
_queryComponents
[
$pathExp
->
getIdentificationVariable
()
][
'map'
]
=
$parts
[
0
];
$parts
=
$pathExp
->
parts
;
$this
->
_queryComponents
[
$pathExp
->
identificationVariable
][
'map'
]
=
$parts
[
0
];
return
$pathExp
;
}
...
...
@@ -1593,7 +1581,7 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_IDENTIFIER
))
{
$token
=
$this
->
_lexer
->
lookahead
;
$resultVariable
=
$this
->
ResultVariable
();
$expr
->
setFieldIdentificationVariable
(
$resultVariable
)
;
$expr
->
fieldIdentificationVariable
=
$resultVariable
;
// Include ResultVariable in query components.
$this
->
_queryComponents
[
$resultVariable
]
=
array
(
...
...
@@ -1657,7 +1645,10 @@ class Parser
$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
// Check if unmatched parenthesis is > 0, then we found a matching arithmetic operator
if
(
$numUnmatched
>
0
)
{
$condPrimary
->
s
etSimpleConditionalExpression
(
$this
->
SimpleConditionalExpression
()
);
$condPrimary
->
s
impleConditionalExpression
=
$this
->
SimpleConditionalExpression
(
);
}
else
{
$this
->
match
(
'('
);
$condPrimary
->
setConditionalExpression
(
$this
->
ConditionalExpression
()
);
$condPrimary
->
conditionalExpression
=
$this
->
ConditionalExpression
(
);
$this
->
match
(
')'
);
}
}
else
{
$condPrimary
->
s
etSimpleConditionalExpression
(
$this
->
SimpleConditionalExpression
()
);
$condPrimary
->
s
impleConditionalExpression
=
$this
->
SimpleConditionalExpression
(
);
}
return
$condPrimary
;
...
...
@@ -1799,7 +1790,7 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$emptyColletionCompExpr
->
setNot
(
true
)
;
$emptyColletionCompExpr
->
not
=
true
;
}
$this
->
match
(
Lexer
::
T_EMPTY
);
...
...
@@ -1817,12 +1808,12 @@ class Parser
*/
public
function
CollectionMemberExpression
()
{
$
isN
ot
=
false
;
$
n
ot
=
false
;
$entityExpr
=
$this
->
EntityExpression
();
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$
isN
ot
=
true
;
$
n
ot
=
true
;
$this
->
match
(
Lexer
::
T_NOT
);
}
...
...
@@ -1832,9 +1823,12 @@ class Parser
$this
->
match
(
Lexer
::
T_OF
);
}
return
new
AST\CollectionMemberExpression
(
$entityExpr
,
$this
->
CollectionValuedPathExpression
()
,
$isNot
$collMemberExpr
=
new
AST\CollectionMemberExpression
(
$entityExpr
,
$this
->
CollectionValuedPathExpression
()
);
$collMemberExpr
->
not
=
$not
;
return
$collMemberExpr
;
}
...
...
@@ -1967,17 +1961,17 @@ class Parser
*/
public
function
ArithmeticFactor
()
{
$
pSign
=
$nSign
=
false
;
$
sign
=
null
;
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'+'
)
{
$this
->
match
(
'+'
);
$
pS
ign
=
true
;
$
s
ign
=
true
;
}
else
if
(
$this
->
_lexer
->
lookahead
[
'value'
]
==
'-'
)
{
$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
*/
public
function
QuantifiedExpression
()
{
$
all
=
$any
=
$some
=
false
;
$
type
=
''
;
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ALL
))
{
$this
->
match
(
Lexer
::
T_ALL
);
$
all
=
true
;
$
type
=
'ALL'
;
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_ANY
))
{
$this
->
match
(
Lexer
::
T_ANY
);
$any
=
true
;
$type
=
'ANY'
;
}
else
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SOME
))
{
$this
->
match
(
Lexer
::
T_SOME
);
$some
=
true
;
$type
=
'SOME'
;
}
else
{
$this
->
syntaxError
(
'ALL, ANY or SOME'
);
}
$this
->
match
(
'('
);
$qExpr
=
new
AST\QuantifiedExpression
(
$this
->
Subselect
());
$qExpr
->
type
=
$type
;
$this
->
match
(
')'
);
$qExpr
->
setAll
(
$all
);
$qExpr
->
setAny
(
$any
);
$qExpr
->
setSome
(
$some
);
return
$qExpr
;
}
...
...
@@ -2218,7 +2209,7 @@ class Parser
$arithExpr3
=
$this
->
ArithmeticExpression
();
$betweenExpr
=
new
AST\BetweenExpression
(
$arithExpr1
,
$arithExpr2
,
$arithExpr3
);
$betweenExpr
->
setNot
(
$not
)
;
$betweenExpr
->
not
=
$not
;
return
$betweenExpr
;
}
...
...
@@ -2255,14 +2246,14 @@ class Parser
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$inExpression
->
setNot
(
true
)
;
$inExpression
->
not
=
true
;
}
$this
->
match
(
Lexer
::
T_IN
);
$this
->
match
(
'('
);
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_SELECT
))
{
$inExpression
->
s
etSubselect
(
$this
->
Subselect
()
);
$inExpression
->
s
ubselect
=
$this
->
Subselect
(
);
}
else
{
$literals
=
array
();
$literals
[]
=
$this
->
InParameter
();
...
...
@@ -2272,7 +2263,7 @@ class Parser
$literals
[]
=
$this
->
InParameter
();
}
$inExpression
->
setLiterals
(
$literals
)
;
$inExpression
->
literals
=
$literals
;
}
$this
->
match
(
')'
);
...
...
@@ -2288,11 +2279,11 @@ class Parser
public
function
LikeExpression
()
{
$stringExpr
=
$this
->
StringExpression
();
$
isN
ot
=
false
;
$
n
ot
=
false
;
if
(
$this
->
_lexer
->
lookahead
[
'type'
]
===
Lexer
::
T_NOT
)
{
$this
->
match
(
Lexer
::
T_NOT
);
$
isN
ot
=
true
;
$
n
ot
=
true
;
}
$this
->
match
(
Lexer
::
T_LIKE
);
...
...
@@ -2313,7 +2304,10 @@ class Parser
$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
if
(
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_NOT
))
{
$this
->
match
(
Lexer
::
T_NOT
);
$nullCompExpr
->
setNot
(
true
)
;
$nullCompExpr
->
not
=
true
;
}
$this
->
match
(
Lexer
::
T_NULL
);
...
...
@@ -2360,8 +2354,8 @@ class Parser
$this
->
match
(
Lexer
::
T_EXISTS
);
$this
->
match
(
'('
);
$existsExpression
=
new
AST\ExistsExpression
(
$this
->
Subselect
());
$existsExpression
->
not
=
$not
;
$this
->
match
(
')'
);
$existsExpression
->
setNot
(
$not
);
return
$existsExpression
;
}
...
...
lib/Doctrine/ORM/Query/SqlWalker.php
View file @
33fc28ff
...
...
@@ -122,11 +122,144 @@ class SqlWalker implements TreeWalker
return
$this
->
_em
;
}
/**
* Gets the Query Component related to the given DQL alias.
*
* @param string $dqlAlias DQL alias
* @return array
*/
public
function
getQueryComponent
(
$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.
*
...
...
@@ -134,18 +267,18 @@ class SqlWalker implements TreeWalker
*/
public
function
walkSelectStatement
(
AST\SelectStatement
$AST
)
{
$sql
=
$this
->
walkSelectClause
(
$AST
->
getSelectClause
()
);
$sql
.=
$this
->
walkFromClause
(
$AST
->
getFromClause
()
);
$sql
=
$this
->
walkSelectClause
(
$AST
->
selectClause
);
$sql
.=
$this
->
walkFromClause
(
$AST
->
fromClause
);
if
(
$whereClause
=
$AST
->
getWhereClause
()
)
{
if
(
$whereClause
=
$AST
->
whereClause
)
{
$sql
.=
$this
->
walkWhereClause
(
$whereClause
);
}
else
if
(
$discSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
))
{
$sql
.=
' WHERE '
.
$discSql
;
}
$sql
.=
$AST
->
g
etGroupByClause
()
?
$this
->
walkGroupByClause
(
$AST
->
getGroupByClause
()
)
:
''
;
$sql
.=
$AST
->
getHavingClause
()
?
$this
->
walkHavingClause
(
$AST
->
getHavingClause
()
)
:
''
;
$sql
.=
$AST
->
getOrderByClause
()
?
$this
->
walkOrderByClause
(
$AST
->
getOrderByClause
()
)
:
''
;
$sql
.=
$AST
->
g
roupByClause
?
$this
->
walkGroupByClause
(
$AST
->
groupByClause
)
:
''
;
$sql
.=
$AST
->
havingClause
?
$this
->
walkHavingClause
(
$AST
->
havingClause
)
:
''
;
$sql
.=
$AST
->
orderByClause
?
$this
->
walkOrderByClause
(
$AST
->
orderByClause
)
:
''
;
$q
=
$this
->
getQuery
();
$sql
=
$this
->
getConnection
()
->
getDatabasePlatform
()
->
modifyLimitQuery
(
...
...
@@ -155,6 +288,66 @@ class SqlWalker implements TreeWalker
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.
*
...
...
@@ -162,8 +355,8 @@ class SqlWalker implements TreeWalker
*/
public
function
walkSelectClause
(
$selectClause
)
{
$sql
=
'SELECT '
.
((
$selectClause
->
isDistinct
()
)
?
'DISTINCT '
:
''
)
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkSelectExpression'
),
$selectClause
->
getSelectExpressions
()
)
$sql
=
'SELECT '
.
((
$selectClause
->
isDistinct
)
?
'DISTINCT '
:
''
)
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkSelectExpression'
),
$selectClause
->
selectExpressions
)
);
foreach
(
$this
->
_selectedClasses
as
$dqlAlias
=>
$class
)
{
...
...
@@ -201,13 +394,13 @@ class SqlWalker implements TreeWalker
public
function
walkFromClause
(
$fromClause
)
{
$sql
=
' FROM '
;
$identificationVarDecls
=
$fromClause
->
getIdentificationVariableDeclarations
()
;
$identificationVarDecls
=
$fromClause
->
identificationVariableDeclarations
;
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$rangeDecl
=
$firstIdentificationVarDecl
->
getRangeVariableDeclaration
()
;
$dqlAlias
=
$rangeDecl
->
getAliasIdentificationVariable
()
;
$rangeDecl
=
$firstIdentificationVarDecl
->
rangeVariableDeclaration
;
$dqlAlias
=
$rangeDecl
->
aliasIdentificationVariable
;
$this
->
_currentRootAlias
=
$dqlAlias
;
$class
=
$rangeDecl
->
getClassMetadata
()
;
$class
=
$rangeDecl
->
classMetadata
;
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
())
.
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$dqlAlias
);
...
...
@@ -216,7 +409,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_generateClassTableInheritanceJoins
(
$class
,
$dqlAlias
);
}
foreach
(
$firstIdentificationVarDecl
->
getJoinVariableDeclarations
()
as
$joinVarDecl
)
{
foreach
(
$firstIdentificationVarDecl
->
joinVariableDeclarations
as
$joinVarDecl
)
{
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
}
...
...
@@ -243,7 +436,7 @@ class SqlWalker implements TreeWalker
{
// OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
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
*/
public
function
walkOrderByItem
(
$orderByItem
)
{
$expr
=
$orderByItem
->
getExpression
()
;
$parts
=
$expr
->
getParts
()
;
$dqlAlias
=
$expr
->
getIdentificationVariable
()
;
$expr
=
$orderByItem
->
expression
;
$parts
=
$expr
->
parts
;
$dqlAlias
=
$expr
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
$sql
=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
(
$orderByItem
->
isDesc
()
?
' DESC'
:
' ASC'
);
return
$sql
;
return
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
' '
.
strtoupper
(
$orderByItem
->
type
);
}
/**
...
...
@@ -279,7 +469,7 @@ class SqlWalker implements TreeWalker
$condExpr
=
$havingClause
->
getConditionalExpression
();
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
*/
public
function
walkJoinVariableDeclaration
(
$joinVarDecl
)
{
$join
=
$joinVarDecl
->
getJoin
()
;
$joinType
=
$join
->
getJoinType
()
;
$join
=
$joinVarDecl
->
join
;
$joinType
=
$join
->
joinType
;
if
(
$joinType
==
AST\Join
::
JOIN_TYPE_LEFT
||
$joinType
==
AST\Join
::
JOIN_TYPE_LEFTOUTER
)
{
$sql
=
' LEFT JOIN '
;
...
...
@@ -300,15 +490,15 @@ class SqlWalker implements TreeWalker
$sql
=
' INNER JOIN '
;
}
$joinAssocPathExpr
=
$join
->
getJoinAssociationPathExpression
()
;
$joinedDqlAlias
=
$join
->
getAliasIdentificationVariable
()
;
$sourceQComp
=
$this
->
_queryComponents
[
$joinAssocPathExpr
->
getIdentificationVariable
()
];
$joinAssocPathExpr
=
$join
->
joinAssociationPathExpression
;
$joinedDqlAlias
=
$join
->
aliasIdentificationVariable
;
$sourceQComp
=
$this
->
_queryComponents
[
$joinAssocPathExpr
->
identificationVariable
];
$targetQComp
=
$this
->
_queryComponents
[
$joinedDqlAlias
];
$targetTableName
=
$targetQComp
[
'metadata'
]
->
getTableName
();
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetTableName
,
$joinedDqlAlias
);
$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
...
...
@@ -322,6 +512,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$targetTableName
)
.
' '
.
$targetTableAlias
.
' ON '
;
$joinColumns
=
$assoc
->
getSourceToTargetKeyColumns
();
$first
=
true
;
foreach
(
$joinColumns
as
$sourceColumn
=>
$targetColumn
)
{
if
(
!
$first
)
{
$sql
.=
' AND '
;
...
...
@@ -409,13 +600,14 @@ class SqlWalker implements TreeWalker
public
function
walkSelectExpression
(
$selectExpression
)
{
$sql
=
''
;
$expr
=
$selectExpression
->
getExpression
();
$expr
=
$selectExpression
->
expression
;
if
(
$expr
instanceof
AST\PathExpression
)
{
if
(
$expr
->
getType
()
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
$parts
=
$expr
->
getParts
()
;
if
(
$expr
->
type
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
$parts
=
$expr
->
parts
;
$numParts
=
count
(
$parts
);
$dqlAlias
=
$expr
->
getIdentificationVariable
()
;
$fieldName
=
$parts
[
$numParts
-
1
];
$dqlAlias
=
$expr
->
identificationVariable
;
$fieldName
=
$parts
[
$numParts
-
1
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$class
=
$qComp
[
'metadata'
];
...
...
@@ -431,13 +623,15 @@ class SqlWalker implements TreeWalker
$this
->
_rsm
->
addFieldResult
(
$dqlAlias
,
$columnAlias
,
$fieldName
);
}
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
)
{
if
(
!
$selectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$selectExpression
->
fieldIdentificationVariable
)
{
$resultAlias
=
$this
->
_scalarResultCounter
++
;
}
else
{
$resultAlias
=
$selectExpression
->
getFieldIdentificationVariable
()
;
$resultAlias
=
$selectExpression
->
fieldIdentificationVariable
;
}
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
...
...
@@ -447,10 +641,10 @@ class SqlWalker implements TreeWalker
}
else
if
(
$expr
instanceof
AST\Subselect
)
{
$sql
.=
$this
->
walkSubselect
(
$expr
);
}
else
if
(
$expr
instanceof
AST\Functions\FunctionNode
)
{
if
(
!
$selectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$selectExpression
->
fieldIdentificationVariable
)
{
$resultAlias
=
$this
->
_scalarResultCounter
++
;
}
else
{
$resultAlias
=
$selectExpression
->
getFieldIdentificationVariable
()
;
$resultAlias
=
$selectExpression
->
fieldIdentificationVariable
;
}
$columnAlias
=
'sclr'
.
$this
->
_aliasCounter
++
;
...
...
@@ -540,7 +734,8 @@ class SqlWalker implements TreeWalker
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
())
{
foreach
(
$assoc
->
targetToSourceKeyColumns
as
$srcColumn
)
{
$columnAlias
=
$this
->
getSqlColumnAlias
(
$srcColumn
);
$sql
.=
', '
.
$sqlTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$srcColumn
)
$sql
.=
', '
.
$sqlTableAlias
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$srcColumn
)
.
' AS '
.
$columnAlias
;
$this
->
_rsm
->
addMetaResult
(
$dqlAlias
,
$columnAlias
,
$srcColumn
);
...
...
@@ -563,13 +758,8 @@ class SqlWalker implements TreeWalker
*/
public
function
walkQuantifiedExpression
(
$qExpr
)
{
$sql
=
''
;
if
(
$qExpr
->
isAll
())
$sql
.=
' ALL'
;
else
if
(
$qExpr
->
isAny
())
$sql
.=
' ANY'
;
else
if
(
$qExpr
->
isSome
())
$sql
.=
' SOME'
;
return
$sql
.=
'('
.
$this
->
walkSubselect
(
$qExpr
->
getSubselect
())
.
')'
;
return
' '
.
strtoupper
(
$qExpr
->
type
)
.
'('
.
$this
->
walkSubselect
(
$qExpr
->
getSubselect
())
.
')'
;
}
/**
...
...
@@ -583,12 +773,12 @@ class SqlWalker implements TreeWalker
$useAliasesBefore
=
$this
->
_useSqlTableAliases
;
$this
->
_useSqlTableAliases
=
true
;
$sql
=
$this
->
walkSimpleSelectClause
(
$subselect
->
getSimpleSelectClause
()
);
$sql
.=
$this
->
walkSubselectFromClause
(
$subselect
->
getSubselectFromClause
()
);
$sql
.=
$subselect
->
getWhereClause
()
?
$this
->
walkWhereClause
(
$subselect
->
getWhereClause
()
)
:
''
;
$sql
.=
$subselect
->
g
etGroupByClause
()
?
$this
->
walkGroupByClause
(
$subselect
->
getGroupByClause
()
)
:
''
;
$sql
.=
$subselect
->
getHavingClause
()
?
$this
->
walkHavingClause
(
$subselect
->
getHavingClause
()
)
:
''
;
$sql
.=
$subselect
->
getOrderByClause
()
?
$this
->
walkOrderByClause
(
$subselect
->
getOrderByClause
()
)
:
''
;
$sql
=
$this
->
walkSimpleSelectClause
(
$subselect
->
simpleSelectClause
);
$sql
.=
$this
->
walkSubselectFromClause
(
$subselect
->
subselectFromClause
);
$sql
.=
$subselect
->
whereClause
?
$this
->
walkWhereClause
(
$subselect
->
whereClause
)
:
''
;
$sql
.=
$subselect
->
g
roupByClause
?
$this
->
walkGroupByClause
(
$subselect
->
groupByClause
)
:
''
;
$sql
.=
$subselect
->
havingClause
?
$this
->
walkHavingClause
(
$subselect
->
havingClause
)
:
''
;
$sql
.=
$subselect
->
orderByClause
?
$this
->
walkOrderByClause
(
$subselect
->
orderByClause
)
:
''
;
$this
->
_useSqlTableAliases
=
$useAliasesBefore
;
...
...
@@ -603,15 +793,15 @@ class SqlWalker implements TreeWalker
*/
public
function
walkSubselectFromClause
(
$subselectFromClause
)
{
$sql
=
' FROM '
;
$identificationVarDecls
=
$subselectFromClause
->
getSubselectIdentificationVariableDeclarations
();
$identificationVarDecls
=
$subselectFromClause
->
identificationVariableDeclarations
;
$firstIdentificationVarDecl
=
$identificationVarDecls
[
0
];
$rangeDecl
=
$firstIdentificationVarDecl
->
getRangeVariableDeclaration
();
$rangeDecl
=
$firstIdentificationVarDecl
->
rangeVariableDeclaration
;
$tblName
=
$rangeDecl
->
classMetadata
->
getTableName
();
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$rangeDecl
->
getClassMetadata
()
->
getTableName
()
)
.
' '
.
$this
->
getSqlTableAlias
(
$rangeDecl
->
getClassMetadata
()
->
getTableName
(),
$rangeDecl
->
getAliasIdentificationVariable
()
);
$sql
=
' FROM '
.
$this
->
_conn
->
quoteIdentifier
(
$tblName
)
.
' '
.
$this
->
getSqlTableAlias
(
$tblName
,
$rangeDecl
->
aliasIdentificationVariable
);
foreach
(
$firstIdentificationVarDecl
->
getJoinVariableDeclarations
()
as
$joinVarDecl
)
{
foreach
(
$firstIdentificationVarDecl
->
joinVariableDeclarations
as
$joinVarDecl
)
{
$sql
.=
$this
->
walkJoinVariableDeclaration
(
$joinVarDecl
);
}
...
...
@@ -626,15 +816,8 @@ class SqlWalker implements TreeWalker
*/
public
function
walkSimpleSelectClause
(
$simpleSelectClause
)
{
$sql
=
'SELECT'
;
if
(
$simpleSelectClause
->
isDistinct
())
{
$sql
.=
' DISTINCT'
;
}
$sql
.=
$this
->
walkSimpleSelectExpression
(
$simpleSelectClause
->
getSimpleSelectExpression
());
return
$sql
;
return
'SELECT'
.
(
$simpleSelectClause
->
isDistinct
?
' DISTINCT'
:
''
)
.
$this
->
walkSimpleSelectExpression
(
$simpleSelectClause
->
simpleSelectExpression
);
}
/**
...
...
@@ -646,16 +829,16 @@ class SqlWalker implements TreeWalker
public
function
walkSimpleSelectExpression
(
$simpleSelectExpression
)
{
$sql
=
''
;
$expr
=
$simpleSelectExpression
->
getExpression
()
;
$expr
=
$simpleSelectExpression
->
expression
;
if
(
$expr
instanceof
AST\PathExpression
)
{
$sql
.=
' '
.
$this
->
walkPathExpression
(
$expr
);
//...
}
else
if
(
$expr
instanceof
AST\AggregateExpression
)
{
if
(
!
$simpleSelectExpression
->
getFieldIdentificationVariable
()
)
{
if
(
!
$simpleSelectExpression
->
fieldIdentificationVariable
)
{
$alias
=
$this
->
_scalarAliasCounter
++
;
}
else
{
$alias
=
$simpleSelectExpression
->
getFieldIdentificationVariable
()
;
$alias
=
$simpleSelectExpression
->
fieldIdentificationVariable
;
}
$sql
.=
$this
->
walkAggregateExpression
(
$expr
)
.
' AS dctrn__'
.
$alias
;
...
...
@@ -664,8 +847,8 @@ class SqlWalker implements TreeWalker
// FIXME: Composite key support, or select all columns? Does that make
// in a subquery?
$class
=
$this
->
_queryComponents
[
$expr
][
'metadata'
];
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$expr
)
.
'.'
;
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getColumnName
(
$class
->
identifier
[
0
]));
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
(),
$expr
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$class
->
getColumnName
(
$class
->
identifier
[
0
]));
}
return
$sql
;
...
...
@@ -680,21 +863,16 @@ class SqlWalker implements TreeWalker
public
function
walkAggregateExpression
(
$aggExpression
)
{
$sql
=
''
;
$parts
=
$aggExpression
->
pathExpression
->
getParts
()
;
$dqlAlias
=
$aggExpression
->
pathExpression
->
getIdentificationVariable
()
;
$parts
=
$aggExpression
->
pathExpression
->
parts
;
$dqlAlias
=
$aggExpression
->
pathExpression
->
identificationVariable
;
$fieldName
=
$parts
[
0
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$fieldName
);
$sql
.=
$aggExpression
->
functionName
.
'('
;
if
(
$aggExpression
->
isDistinct
)
$sql
.=
'DISTINCT '
;
$sql
.=
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
return
$aggExpression
->
functionName
.
'('
.
(
$aggExpression
->
isDistinct
?
'DISTINCT '
:
''
)
.
$this
->
getSqlTableAlias
(
$qComp
[
'metadata'
]
->
getTableName
(),
$dqlAlias
)
.
'.'
.
$this
->
_conn
->
quoteIdentifier
(
$columnName
)
.
')'
;
return
$sql
;
}
/**
...
...
@@ -706,7 +884,7 @@ class SqlWalker implements TreeWalker
public
function
walkGroupByClause
(
$groupByClause
)
{
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
*/
public
function
walkGroupByItem
(
AST\PathExpression
$pathExpr
)
{
$parts
=
$pathExpr
->
getParts
()
;
$dqlAlias
=
$pathExpr
->
getIdentificationVariable
()
;
$parts
=
$pathExpr
->
parts
;
$dqlAlias
=
$pathExpr
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$columnName
=
$qComp
[
'metadata'
]
->
getColumnName
(
$parts
[
0
]);
...
...
@@ -727,46 +905,6 @@ class SqlWalker implements TreeWalker
.
$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.
*
...
...
@@ -776,14 +914,14 @@ class SqlWalker implements TreeWalker
public
function
walkDeleteClause
(
AST\DeleteClause
$deleteClause
)
{
$sql
=
'DELETE FROM '
;
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
getAbstractSchemaName
()
);
$class
=
$this
->
_em
->
getClassMetadata
(
$deleteClause
->
abstractSchemaName
);
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
if
(
$this
->
_useSqlTableAliases
)
{
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
}
$this
->
_currentRootAlias
=
$deleteClause
->
getAliasIdentificationVariable
()
;
$this
->
_currentRootAlias
=
$deleteClause
->
aliasIdentificationVariable
;
return
$sql
;
}
...
...
@@ -797,17 +935,17 @@ class SqlWalker implements TreeWalker
public
function
walkUpdateClause
(
$updateClause
)
{
$sql
=
'UPDATE '
;
$class
=
$this
->
_em
->
getClassMetadata
(
$updateClause
->
getAbstractSchemaName
()
);
$class
=
$this
->
_em
->
getClassMetadata
(
$updateClause
->
abstractSchemaName
);
$sql
.=
$this
->
_conn
->
quoteIdentifier
(
$class
->
getTableName
());
if
(
$this
->
_useSqlTableAliases
)
{
$sql
.=
' '
.
$this
->
getSqlTableAlias
(
$class
->
getTableName
());
}
$this
->
_currentRootAlias
=
$updateClause
->
getAliasIdentificationVariable
()
;
$this
->
_currentRootAlias
=
$updateClause
->
aliasIdentificationVariable
;
$sql
.=
' SET '
.
implode
(
', '
,
array_map
(
array
(
$this
,
'walkUpdateItem'
),
$updateClause
->
getUpdateItems
()
)
', '
,
array_map
(
array
(
$this
,
'walkUpdateItem'
),
$updateClause
->
updateItems
)
);
return
$sql
;
...
...
@@ -825,16 +963,16 @@ class SqlWalker implements TreeWalker
$this
->
_useSqlTableAliases
=
false
;
$sql
=
''
;
$dqlAlias
=
$updateItem
->
getIdentificationVariable
()
;
$dqlAlias
=
$updateItem
->
identificationVariable
;
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
if
(
$this
->
_useSqlTableAliases
)
{
$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
)
{
$sql
.=
$newValue
->
dispatch
(
$this
);
...
...
@@ -860,10 +998,10 @@ class SqlWalker implements TreeWalker
public
function
walkWhereClause
(
$whereClause
)
{
$sql
=
' WHERE '
;
$condExpr
=
$whereClause
->
getConditionalExpression
()
;
$condExpr
=
$whereClause
->
conditionalExpression
;
$sql
.=
implode
(
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
getConditionalTerms
()
)
' OR '
,
array_map
(
array
(
$this
,
'walkConditionalTerm'
),
$condExpr
->
conditionalTerms
)
);
$discrSql
=
$this
->
_generateDiscriminatorColumnConditionSql
(
$this
->
_currentRootAlias
);
...
...
@@ -919,7 +1057,7 @@ class SqlWalker implements TreeWalker
public
function
walkConditionalTerm
(
$condTerm
)
{
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
*/
public
function
walkConditionalFactor
(
$factor
)
{
$sql
=
''
;
$sql
=
(
$factor
->
not
)
?
'NOT '
:
''
;
if
(
$factor
->
isNot
())
$sql
.=
'NOT '
;
$primary
=
$factor
->
getConditionalPrimary
();
$primary
=
$factor
->
conditionalPrimary
;
if
(
$primary
->
isSimpleConditionalExpression
())
{
$sql
.=
$primary
->
getSimpleConditionalExpression
()
->
dispatch
(
$this
);
$sql
.=
$primary
->
simpleConditionalExpression
->
dispatch
(
$this
);
}
else
if
(
$primary
->
isConditionalExpression
())
{
$condExpr
=
$primary
->
getConditionalExpression
();
$condExpr
=
$primary
->
conditionalExpression
;
$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
*/
public
function
walkExistsExpression
(
$existsExpr
)
{
$sql
=
''
;
$sql
=
(
$existsExpr
->
not
)
?
'NOT '
:
''
;
if
(
$existsExpr
->
isNot
())
$sql
.=
' NOT'
;
$sql
.=
'EXISTS ('
.
$this
->
walkSubselect
(
$existsExpr
->
getSubselect
())
.
')'
;
$sql
.=
'EXISTS ('
.
$this
->
walkSubselect
(
$existsExpr
->
subselect
)
.
')'
;
return
$sql
;
}
...
...
@@ -974,17 +1109,17 @@ class SqlWalker implements TreeWalker
*/
public
function
walkCollectionMemberExpression
(
$collMemberExpr
)
{
$sql
=
$collMemberExpr
->
isN
ot
?
'NOT '
:
''
;
$sql
=
$collMemberExpr
->
n
ot
?
'NOT '
:
''
;
$sql
.=
'EXISTS (SELECT 1 FROM '
;
$entityExpr
=
$collMemberExpr
->
entityExpression
;
$collPathExpr
=
$collMemberExpr
->
collectionValuedPathExpression
;
$parts
=
$collPathExpr
->
getParts
()
;
$dqlAlias
=
$collPathExpr
->
getIdentificationVariable
()
;
$parts
=
$collPathExpr
->
parts
;
$dqlAlias
=
$collPathExpr
->
identificationVariable
;
$class
=
$this
->
_queryComponents
[
$dqlAlias
][
'metadata'
];
if
(
$entityExpr
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$entityExpr
->
isNamed
()
?
$entityExpr
->
getName
()
:
$entityExpr
->
getPosition
()
;
$dqlParamKey
=
$entityExpr
->
name
;
$entity
=
$this
->
_query
->
getParameter
(
$dqlParamKey
);
}
else
{
//TODO
...
...
@@ -1026,7 +1161,9 @@ class SqlWalker implements TreeWalker
}
else
{
// many-to-many
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$assoc
->
targetEntityName
);
$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'
]);
$targetTableAlias
=
$this
->
getSqlTableAlias
(
$targetClass
->
primaryTable
[
'name'
]);
...
...
@@ -1037,7 +1174,9 @@ class SqlWalker implements TreeWalker
.
' '
.
$targetTableAlias
.
' ON '
;
// join conditions
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'joinColumns'
]
:
$joinTable
[
'inverseJoinColumns'
];
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'joinColumns'
]
:
$joinTable
[
'inverseJoinColumns'
];
$first
=
true
;
foreach
(
$joinColumns
as
$joinColumn
)
{
...
...
@@ -1050,7 +1189,9 @@ class SqlWalker implements TreeWalker
$sql
.=
' WHERE '
;
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'inverseJoinColumns'
]
:
$joinTable
[
'joinColumns'
];
$joinColumns
=
$assoc
->
isOwningSide
?
$joinTable
[
'inverseJoinColumns'
]
:
$joinTable
[
'joinColumns'
];
$first
=
true
;
foreach
(
$joinColumns
as
$joinColumn
)
{
...
...
@@ -1085,12 +1226,9 @@ class SqlWalker implements TreeWalker
public
function
walkEmptyCollectionComparisonExpression
(
$emptyCollCompExpr
)
{
$sizeFunc
=
new
AST\Functions\SizeFunction
(
'size'
);
$sizeFunc
->
setCollectionPathExpression
(
$emptyCollCompExpr
->
getExpression
());
$sql
=
$sizeFunc
->
getSql
(
$this
);
$sql
.=
(
$emptyCollCompExpr
->
isNot
()
?
' > 0'
:
' = 0'
);
$sizeFunc
->
collectionPathExpression
=
$emptyCollCompExpr
->
expression
;
return
$s
ql
;
return
$s
izeFunc
->
getSql
(
$this
)
.
(
$emptyCollCompExpr
->
not
?
' > 0'
:
' = 0'
)
;
}
/**
...
...
@@ -1102,17 +1240,17 @@ class SqlWalker implements TreeWalker
public
function
walkNullComparisonExpression
(
$nullCompExpr
)
{
$sql
=
''
;
$innerExpr
=
$nullCompExpr
->
getExpression
()
;
$innerExpr
=
$nullCompExpr
->
expression
;
if
(
$innerExpr
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$innerExpr
->
isNamed
()
?
$innerExpr
->
getName
()
:
$innerExpr
->
getPosition
()
;
$dqlParamKey
=
$innerExpr
->
name
;
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$sql
.=
' ?'
;
// . ($innerExpr->isNamed() ? ':' . $innerExpr->getName() : '?');
$sql
.=
' ?'
;
}
else
{
$sql
.=
$this
->
walkPathExpression
(
$innerExpr
);
}
$sql
.=
' IS'
.
(
$nullCompExpr
->
isNot
()
?
' NOT'
:
''
)
.
' NULL'
;
$sql
.=
' IS'
.
(
$nullCompExpr
->
not
?
' NOT'
:
''
)
.
' NULL'
;
return
$sql
;
}
...
...
@@ -1125,16 +1263,13 @@ class SqlWalker implements TreeWalker
*/
public
function
walkInExpression
(
$inExpr
)
{
$sql
=
$this
->
walkPathExpression
(
$inExpr
->
getPathExpression
());
$sql
=
$this
->
walkPathExpression
(
$inExpr
->
pathExpression
)
.
(
$inExpr
->
not
?
' NOT'
:
''
)
.
' IN ('
;
if
(
$inExpr
->
isNot
())
$sql
.=
' NOT'
;
$sql
.=
' IN ('
;
if
(
$inExpr
->
getSubselect
())
{
$sql
.=
$this
->
walkSubselect
(
$inExpr
->
getSubselect
());
if
(
$inExpr
->
subselect
)
{
$sql
.=
$this
->
walkSubselect
(
$inExpr
->
subselect
);
}
else
{
$sql
.=
implode
(
', '
,
array_map
(
array
(
$this
,
'walkLiteral'
),
$inExpr
->
getLiterals
()
));
$sql
.=
implode
(
', '
,
array_map
(
array
(
$this
,
'walkLiteral'
),
$inExpr
->
literals
));
}
$sql
.=
')'
;
...
...
@@ -1151,10 +1286,7 @@ class SqlWalker implements TreeWalker
public
function
walkLiteral
(
$literal
)
{
if
(
$literal
instanceof
AST\InputParameter
)
{
$dqlParamKey
=
$literal
->
isNamed
()
?
$literal
->
getName
()
:
$literal
->
getPosition
();
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
return
'?'
;
return
$this
->
walkInputParameter
(
$literal
);
}
return
$literal
;
//TODO: quote() ?
...
...
@@ -1168,12 +1300,12 @@ class SqlWalker implements TreeWalker
*/
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
()
)
.
' AND '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
getRightBetweenExpression
()
);
$sql
.=
' BETWEEN '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
leftBetweenExpression
)
.
' AND '
.
$this
->
walkArithmeticExpression
(
$betweenExpr
->
rightBetweenExpression
);
return
$sql
;
}
...
...
@@ -1186,24 +1318,20 @@ class SqlWalker implements TreeWalker
*/
public
function
walkLikeExpression
(
$likeExpr
)
{
$stringExpr
=
$likeExpr
->
getStringExpression
();
$sql
=
$stringExpr
->
dispatch
(
$this
);
if
(
$likeExpr
->
isNot
())
$sql
.=
' NOT'
;
$stringExpr
=
$likeExpr
->
stringExpression
;
$sql
=
$stringExpr
->
dispatch
(
$this
)
.
(
$likeExpr
->
not
?
' NOT'
:
''
)
.
' LIKE '
;
$sql
.=
' LIKE '
;
if
(
$likeExpr
->
getStringPattern
()
instanceof
AST\InputParameter
)
{
$inputParam
=
$likeExpr
->
getStringPattern
();
$dqlParamKey
=
$inputParam
->
isNamed
()
?
$inputParam
->
getName
()
:
$inputParam
->
getPosition
();
if
(
$likeExpr
->
stringPattern
instanceof
AST\InputParameter
)
{
$inputParam
=
$likeExpr
->
stringPattern
;
$dqlParamKey
=
$inputParam
->
name
;
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$sql
.=
'?'
;
}
else
{
$sql
.=
$this
->
_conn
->
quote
(
$likeExpr
->
getStringPattern
()
);
$sql
.=
$this
->
_conn
->
quote
(
$likeExpr
->
stringPattern
);
}
if
(
$likeExpr
->
getEscapeChar
()
)
{
$sql
.=
' ESCAPE '
.
$this
->
_conn
->
quote
(
$likeExpr
->
getEscapeChar
()
);
if
(
$likeExpr
->
escapeChar
)
{
$sql
.=
' ESCAPE '
.
$this
->
_conn
->
quote
(
$likeExpr
->
escapeChar
);
}
return
$sql
;
...
...
@@ -1229,8 +1357,8 @@ class SqlWalker implements TreeWalker
public
function
walkComparisonExpression
(
$compExpr
)
{
$sql
=
''
;
$leftExpr
=
$compExpr
->
getLeftExpression
()
;
$rightExpr
=
$compExpr
->
getRightExpression
()
;
$leftExpr
=
$compExpr
->
leftExpression
;
$rightExpr
=
$compExpr
->
rightExpression
;
if
(
$leftExpr
instanceof
AST\Node
)
{
$sql
.=
$leftExpr
->
dispatch
(
$this
);
...
...
@@ -1238,7 +1366,7 @@ class SqlWalker implements TreeWalker
$sql
.=
$this
->
_conn
->
quote
(
$leftExpr
);
}
$sql
.=
' '
.
$compExpr
->
getOperator
()
.
' '
;
$sql
.=
' '
.
$compExpr
->
operator
.
' '
;
if
(
$rightExpr
instanceof
AST\Node
)
{
$sql
.=
$rightExpr
->
dispatch
(
$this
);
...
...
@@ -1257,8 +1385,7 @@ class SqlWalker implements TreeWalker
*/
public
function
walkInputParameter
(
$inputParam
)
{
$dqlParamKey
=
$inputParam
->
isNamed
()
?
$inputParam
->
getName
()
:
$inputParam
->
getPosition
();
$this
->
_parserResult
->
addParameterMapping
(
$dqlParamKey
,
$this
->
_sqlParamIndex
++
);
$this
->
_parserResult
->
addParameterMapping
(
$inputParam
->
name
,
$this
->
_sqlParamIndex
++
);
return
'?'
;
}
...
...
@@ -1287,7 +1414,7 @@ class SqlWalker implements TreeWalker
if
(
is_string
(
$term
))
return
$term
;
return
implode
(
' '
,
array_map
(
array
(
$this
,
'walkArithmeticFactor'
),
$term
->
getArithmeticFactors
()
)
' '
,
array_map
(
array
(
$this
,
'walkArithmeticFactor'
),
$term
->
arithmeticFactors
)
);
}
...
...
@@ -1314,11 +1441,11 @@ class SqlWalker implements TreeWalker
{
if
(
is_string
(
$factor
))
return
$factor
;
$sql
=
''
;
$primary
=
$factor
->
getArithmeticPrimary
()
;
$sql
=
(
$factor
->
isNegativeSigned
()
?
'-'
:
(
$factor
->
isPositiveSigned
()
?
'+'
:
''
))
;
$primary
=
$factor
->
arithmeticPrimary
;
if
(
is_numeric
(
$primary
))
{
$sql
.=
$primary
;
//
TODO: quote() ?
$sql
.=
$primary
;
//
We should not quote numeric values!
}
else
if
(
is_string
(
$primary
))
{
$sql
.=
$this
->
_conn
->
quote
(
$primary
);
}
else
if
(
$primary
instanceof
AST\SimpleArithmeticExpression
)
{
...
...
@@ -1339,7 +1466,7 @@ class SqlWalker implements TreeWalker
public
function
walkSimpleArithmeticExpression
(
$simpleArithmeticExpr
)
{
return
implode
(
' '
,
array_map
(
array
(
$this
,
'walkArithmeticTerm'
),
$simpleArithmeticExpr
->
getArithmeticTerms
()
)
' '
,
array_map
(
array
(
$this
,
'walkArithmeticTerm'
),
$simpleArithmeticExpr
->
arithmeticTerms
)
);
}
...
...
@@ -1352,13 +1479,13 @@ class SqlWalker implements TreeWalker
public
function
walkPathExpression
(
$pathExpr
)
{
$sql
=
''
;
$pathExprType
=
$pathExpr
->
getType
()
;
$pathExprType
=
$pathExpr
->
type
;
if
(
$pathExprType
==
AST\PathExpression
::
TYPE_STATE_FIELD
)
{
$parts
=
$pathExpr
->
getParts
()
;
$parts
=
$pathExpr
->
parts
;
$numParts
=
count
(
$parts
);
$dqlAlias
=
$pathExpr
->
getIdentificationVariable
()
;
$fieldName
=
$parts
[
$numParts
-
1
];
$dqlAlias
=
$pathExpr
->
identificationVariable
;
$fieldName
=
$parts
[
$numParts
-
1
];
$qComp
=
$this
->
_queryComponents
[
$dqlAlias
];
$class
=
$qComp
[
'metadata'
];
...
...
@@ -1390,130 +1517,4 @@ class SqlWalker implements TreeWalker
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