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
79d04eed
Commit
79d04eed
authored
Feb 08, 2014
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add note into docs about starting with 0 in QueryBuilder.
parent
faa3d22c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
query-builder.rst
docs/en/reference/query-builder.rst
+14
-8
No files found.
docs/en/reference/query-builder.rst
View file @
79d04eed
...
...
@@ -39,9 +39,15 @@ input to any of the methods of the QueryBuilder and use the placeholder
->select('u.id', 'u.name')
->from('users', 'u')
->where('u.email = ?')
->setParameter(
1
, $userInputEmail)
->setParameter(
0
, $userInputEmail)
;
.. note::
Due to an API design error the numerical parameters in the QueryBuilder API
start with the needle ``0``, not with ``1`` as in the PDO API. This is very
unfortunate, but we have found no BC way to fix this.
Building a Query
----------------
...
...
@@ -202,8 +208,8 @@ done with the ``values()`` method on the query builder:
'password' => '?'
)
)
->setParameter(
1
, $username)
->setParameter(
2
, $password)
->setParameter(
0
, $username)
->setParameter(
1
, $password)
;
// INSERT INTO users (name, password) VALUES (?, ?)
...
...
@@ -219,8 +225,8 @@ Setting single values instead of all at once is also possible with the
->insert('users')
->setValue('name', '?')
->setValue('password', '?')
->setParameter(
1
, $username)
->setParameter(
2
, $password)
->setParameter(
0
, $username)
->setParameter(
1
, $password)
;
// INSERT INTO users (name, password) VALUES (?, ?)
...
...
@@ -237,14 +243,14 @@ Of course you can also use both methods in combination:
'name' => '?'
)
)
->setParameter(
1
, $username)
->setParameter(
0
, $username)
;
// INSERT INTO users (name) VALUES (?)
if ($password) {
$queryBuilder
->setValue('password', '?')
->setParameter(
2
, $password)
->setParameter(
1
, $password)
;
// INSERT INTO users (name, password) VALUES (?, ?)
}
...
...
@@ -276,7 +282,7 @@ user-input:
->update('users', 'u')
->set('u.logins', 'u.logins + 1')
->set('u.last_login', '?')
->setParameter(
1
, $userInputLastLogin)
->setParameter(
0
, $userInputLastLogin)
;
Building Expressions
...
...
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