Skip to content

Commit

Permalink
Merge pull request #647 from JeroenDeDauw/docs
Browse files Browse the repository at this point in the history
Update docs to relfect the changes to QueryBuilder::from made in #646
  • Loading branch information
Ocramius committed Aug 1, 2014
2 parents d686e5d + b90e3f9 commit 81aec7c
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions docs/en/reference/query-builder.rst
Expand Up @@ -36,9 +36,9 @@ input to any of the methods of the QueryBuilder and use the placeholder
<?php
$queryBuilder
->select('u.id', 'u.name')
->from('users', 'u')
->where('u.email = ?')
->select('id', 'name')
->from('users')
->where('email = ?')
->setParameter(0, $userInputEmail)
;
Expand All @@ -62,8 +62,8 @@ For ``SELECT`` queries you start with invoking the ``select()`` method
<?php
$queryBuilder
->select('u.id', 'u.name')
->from('users', 'u');
->select('id', 'name')
->from('users');
For ``INSERT``, ``UPDATE`` and ``DELETE`` queries you can pass the
table name into the ``insert($tableName)``, ``update($tableName)``
Expand All @@ -74,15 +74,15 @@ and ``delete($tableName)``:
<?php
$queryBuilder
->insert('users', 'u')
->insert('users')
;
$queryBuilder
->update('users', 'u')
->update('users')
;
$queryBuilder
->delete('users', 'u')
->delete('users')
;
You can convert a query builder to its SQL string representation
Expand All @@ -99,15 +99,31 @@ clauses with the following API:
<?php
$queryBuilder
->select('u.id', 'u.name')
->from('users', 'u')
->where('u.email = ?')
->select('id', 'name')
->from('users')
->where('email = ?')
;
Calling ``where()`` overwrites the previous clause and you can prevent
this by combining expressions with ``andWhere()`` and ``orWhere()`` methods.
You can alternatively use expressions to generate the where clause.

Table alias
~~~~~~~~~~~

The ``from()`` method takes an optional second parameter with which a table
alias can be specified.

.. code-block:: php
<?php
$queryBuilder
->select('u.id', 'u.name')
->from('users', 'u')
->where('u.email = ?')
;
GROUP BY and HAVING Clause
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 81aec7c

Please sign in to comment.