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
c81affb9
Commit
c81affb9
authored
Aug 14, 2009
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Some fixes in Expr. More documentation added.
parent
abc853ec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
18 deletions
+61
-18
Expr.php
lib/Doctrine/ORM/Query/Expr.php
+9
-9
From.php
lib/Doctrine/ORM/Query/Expr/From.php
+48
-0
Func.php
lib/Doctrine/ORM/Query/Expr/Func.php
+2
-2
QueryBuilder.php
lib/Doctrine/ORM/QueryBuilder.php
+2
-2
ExprTest.php
tests/Doctrine/Tests/ORM/Query/ExprTest.php
+0
-5
No files found.
lib/Doctrine/ORM/Query/Expr.php
View file @
c81affb9
...
...
@@ -47,6 +47,11 @@ class Expr
{
return
new
Expr\Select
(
func_get_args
());
}
public
static
function
from
(
$from
,
$alias
=
null
)
{
return
new
Expr\From
(
$from
,
$alias
);
}
public
static
function
orderBy
(
$sort
=
null
,
$order
=
null
)
{
...
...
@@ -113,7 +118,7 @@ class Expr
return
new
Expr\Func
(
'COUNT'
,
array
(
$x
));
}
public
static
function
countDistinct
()
public
static
function
countDistinct
(
$x
)
{
return
'COUNT(DISTINCT '
.
implode
(
', '
,
func_get_args
())
.
')'
;
}
...
...
@@ -183,14 +188,9 @@ class Expr
return
new
Expr\Func
(
$x
.
' NOT IN'
,
(
array
)
$y
);
}
public
static
function
notEqual
(
$x
,
$y
)
{
return
new
Expr\Comparison
(
$x
,
'!='
,
$y
);
}
public
static
function
like
(
$x
,
$y
)
{
return
new
Expr\
Math
(
$x
,
'LIKE'
,
$y
);
return
new
Expr\
Comparison
(
$x
,
'LIKE'
,
$y
);
}
public
static
function
concat
(
$x
,
$y
)
...
...
@@ -232,8 +232,8 @@ class Expr
return
new
Expr\Func
(
'BETWEEN'
,
array
(
$val
,
$x
,
$y
));
}
public
static
function
trim
()
public
static
function
trim
(
$x
)
{
return
new
Expr\Func
(
'TRIM'
,
func_get_args
()
);
return
new
Expr\Func
(
'TRIM'
,
$x
);
}
}
\ No newline at end of file
lib/Doctrine/ORM/Query/Expr/From.php
0 → 100644
View file @
c81affb9
<?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\Expr
;
/**
* Expression class for DQL from
*
* @author Jonathan H. Wage <jonwage@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class
From
{
private
$_from
;
private
$_alias
;
public
function
__construct
(
$from
,
$alias
=
null
)
{
$this
->
_from
=
$from
;
$this
->
_alias
=
$alias
;
}
public
function
__toString
()
{
return
$this
->
_from
.
(
$this
->
_alias
?
' '
.
$this
->
_alias
:
''
);
}
}
\ No newline at end of file
lib/Doctrine/ORM/Query/Expr/Func.php
View file @
c81affb9
...
...
@@ -37,8 +37,8 @@ class Func
public
function
__construct
(
$name
,
$arguments
)
{
$this
->
_name
=
$name
;
$this
->
_arguments
=
$arguments
;
$this
->
_name
=
$name
;
$this
->
_arguments
=
(
array
)
$arguments
;
}
public
function
__toString
()
...
...
lib/Doctrine/ORM/QueryBuilder.php
View file @
c81affb9
...
...
@@ -252,9 +252,9 @@ class QueryBuilder
return
$this
->
add
(
'set'
,
Expr
::
eq
(
$key
,
$value
),
true
);
}
public
function
from
(
$from
,
$alias
)
public
function
from
(
$from
,
$alias
=
null
)
{
return
$this
->
add
(
'from'
,
$from
.
' '
.
$alias
,
true
);
return
$this
->
add
(
'from'
,
Expr
::
from
(
$from
,
$alias
)
,
true
);
}
public
function
innerJoin
(
$parentAlias
,
$join
,
$alias
,
$condition
=
null
)
...
...
tests/Doctrine/Tests/ORM/Query/ExprTest.php
View file @
c81affb9
...
...
@@ -140,11 +140,6 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
$this
->
assertEquals
(
'1 = 1'
,
(
string
)
Expr
::
eq
(
1
,
1
));
}
public
function
testNotEqualExpr
()
{
$this
->
assertEquals
(
'1 != 2'
,
(
string
)
Expr
::
notEqual
(
1
,
2
));
}
public
function
testLikeExpr
()
{
$this
->
assertEquals
(
'a.description LIKE :description'
,
(
string
)
Expr
::
like
(
'a.description'
,
':description'
));
...
...
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