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
fba4a354
Commit
fba4a354
authored
Aug 13, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #659 from JeroenDeDauw/docz
Improve QueryBuilder docs
parents
6d0b0486
1947464b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
query-builder.rst
docs/en/reference/query-builder.rst
+21
-21
No files found.
docs/en/reference/query-builder.rst
View file @
fba4a354
...
...
@@ -137,9 +137,9 @@ previous expressions or ``addGroupBy()`` which adds to them:
<?php
$queryBuilder
->select('DATE(
u.last_login) as date', 'COUNT(u.
id) AS users')
->from('users'
, 'u'
)
->groupBy('DATE(
u.
last_login)')
->select('DATE(
last_login) as date', 'COUNT(
id) AS users')
->from('users')
->groupBy('DATE(last_login)')
->having('users > 10')
;
...
...
@@ -180,10 +180,10 @@ user input and accepts SQL expressions.
<?php
$queryBuilder
->select('
u.id', 'u.name', 'p.number
')
->from('users'
, 'u'
)
->orderBy('u
.u
sername', 'ASC')
->addOrderBy('
u.
last_login', 'ASC NULLS FIRST')
->select('
id', 'name
')
->from('users')
->orderBy('username', 'ASC')
->addOrderBy('last_login', 'ASC NULLS FIRST')
;
Use the ``addOrderBy`` method to add instead of replace the ``orderBy`` clause.
...
...
@@ -201,8 +201,8 @@ returned.
<?php
$queryBuilder
->select('
u.id', 'u.
name')
->from('users'
, 'u'
)
->select('
id', '
name')
->from('users')
->setFirstResult(10)
->setMaxResults(20);
...
...
@@ -315,12 +315,12 @@ Most notably you can use expressions to build nested And-/Or statements:
<?php
$queryBuilder
->select('
u.id', 'u.
name')
->from('users'
, 'u'
)
->select('
id', '
name')
->from('users')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('u
.u
sername', '?'),
$queryBuilder->expr()->eq('
u.
email', '?')
$queryBuilder->expr()->eq('username', '?'),
$queryBuilder->expr()->eq('email', '?')
)
);
...
...
@@ -343,15 +343,15 @@ in your query as a return value:
<?php
$queryBuilder
->select('
u.id', 'u.
name')
->from('users'
, 'u'
)
->where('
u.
email = ' . $queryBuilder->createNamedParameter($userInputEmail))
->select('
id', '
name')
->from('users')
->where('email = ' . $queryBuilder->createNamedParameter($userInputEmail))
;
// SELECT
u.id, u.name FROM users u WHERE u.
email = :dcValue1
// SELECT
id, name FROM users WHERE
email = :dcValue1
$queryBuilder
->select('
u.id', 'u.
name')
->from('users'
, 'u'
)
->where('
u.
email = ' . $queryBuilder->createPositionalParameter($userInputEmail))
->select('
id', '
name')
->from('users')
->where('email = ' . $queryBuilder->createPositionalParameter($userInputEmail))
;
// SELECT
u.id, u.name FROM users u WHERE u.
email = ?
// SELECT
id, name FROM users WHERE
email = ?
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