Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
Did some more work on DBAL ReST documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Dec 12, 2010
1 parent 9f53574 commit 9d60a95
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 69 deletions.
File renamed without changes.
File renamed without changes.
29 changes: 14 additions & 15 deletions reference/en/index.rst → en/index.rst
Expand Up @@ -9,25 +9,24 @@ Welcome to Doctrine DBAL's documentation!
Contents: Contents:


.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
:numbered:


introduction reference/introduction
architecture reference/architecture
configuration reference/configuration
data-retrieval-and-manipulation reference/data-retrieval-and-manipulation
transactions reference/transactions
platforms reference/platforms
types reference/types
schema-manager reference/schema-manager
schema-representation reference/schema-representation
events reference/events
supporting-other-databases reference/supporting-other-databases
known-vendor-issues reference/known-vendor-issues


Indices and tables Indices and tables
================== ==================


* :ref:`genindex`
* :ref:`modindex`
* :ref:`search` * :ref:`search`


File renamed without changes.
File renamed without changes.
Expand Up @@ -7,7 +7,7 @@ Getting a Connection
You can get a DBAL Connection through the You can get a DBAL Connection through the
``Doctrine\DBAL\DriverManager`` class. ``Doctrine\DBAL\DriverManager`` class.


:: .. code-block:: php
<?php <?php
$config = new \Doctrine\DBAL\Configuration(); $config = new \Doctrine\DBAL\Configuration();
Expand Down Expand Up @@ -143,7 +143,6 @@ Custom Driver Options


The ``driverOptions`` option allows to pass arbitrary options The ``driverOptions`` option allows to pass arbitrary options
through to the driver. This is equivalent to the 4th argument of through to the driver. This is equivalent to the 4th argument of
the the `PDO constructor <http://php.net/manual/en/pdo.construct.php>`_.
`PDO constructor <http://php.net/manual/en/pdo.construct.php>`_.




Expand Up @@ -12,7 +12,7 @@ prepare()
Prepare a given sql statement and return the Prepare a given sql statement and return the
``\Doctrine\DBAL\Driver\Statement`` instance: ``\Doctrine\DBAL\Driver\Statement`` instance:


:: .. code-block:: php
<?php <?php
$statement = $conn->prepare('SELECT * FROM user'); $statement = $conn->prepare('SELECT * FROM user');
Expand All @@ -34,7 +34,7 @@ executeUpdate()
Executes a prepared statement with the given sql and parameters and Executes a prepared statement with the given sql and parameters and
returns the affected rows count: returns the affected rows count:


:: .. code-block:: php
<?php <?php
$count = $conn->executeUpdate('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1)); $count = $conn->executeUpdate('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
Expand All @@ -51,7 +51,7 @@ executeQuery()
Creates a prepared statement for the given sql and passes the Creates a prepared statement for the given sql and passes the
parameters to the execute method, then returning the statement: parameters to the execute method, then returning the statement:


:: .. code-block:: php
<?php <?php
$statement = $conn->execute('SELECT * FROM user WHERE username = ?', array('jwage')); $statement = $conn->execute('SELECT * FROM user WHERE username = ?', array('jwage'));
Expand All @@ -74,7 +74,7 @@ fetchAll()


Execute the query and fetch all results into an array: Execute the query and fetch all results into an array:


:: .. code-block:: php
<?php <?php
$users = $conn->fetchAll('SELECT * FROM user'); $users = $conn->fetchAll('SELECT * FROM user');
Expand All @@ -93,7 +93,7 @@ fetchArray()


Numeric index retrieval of first result row of the given query: Numeric index retrieval of first result row of the given query:


:: .. code-block:: php
<?php <?php
$user = $conn->fetchArray('SELECT * FROM user WHERE username = ?', array('jwage')); $user = $conn->fetchArray('SELECT * FROM user WHERE username = ?', array('jwage'));
Expand All @@ -110,7 +110,7 @@ fetchColumn()


Retrieve only the given column of the first result row. Retrieve only the given column of the first result row.


:: .. code-block:: php
<?php <?php
$username = $conn->fetchColumn('SELECT username FROM user WHERE id = ?', array(1), 0); $username = $conn->fetchColumn('SELECT username FROM user WHERE id = ?', array(1), 0);
Expand All @@ -121,7 +121,7 @@ fetchAssoc()


Retrieve assoc row of the first result row. Retrieve assoc row of the first result row.


:: .. code-block:: php
<?php <?php
$user = $conn->fetchAssoc('SELECT * FROM user WHERE username = ?', array('jwage')); $user = $conn->fetchAssoc('SELECT * FROM user WHERE username = ?', array('jwage'));
Expand All @@ -140,7 +140,7 @@ delete()
Delete all rows of a table matching the given identifier, where Delete all rows of a table matching the given identifier, where
keys are column names. keys are column names.


:: .. code-block:: php
<?php <?php
$conn->delete('user', array('id' => 1)); $conn->delete('user', array('id' => 1));
Expand All @@ -152,7 +152,7 @@ insert()
Insert a row into the given table name using the key value pairs of Insert a row into the given table name using the key value pairs of
data. data.


:: .. code-block:: php
<?php <?php
$conn->insert('user', array('username' => 'jwage')); $conn->insert('user', array('username' => 'jwage'));
Expand All @@ -164,7 +164,7 @@ update()
Update all rows for the matching key value identifiers with the Update all rows for the matching key value identifiers with the
given data. given data.


:: .. code-block:: php
<?php <?php
$conn->update('user', array('username' => 'jwage'), array('id' => 1)); $conn->update('user', array('username' => 'jwage'), array('id' => 1));
Expand All @@ -182,7 +182,7 @@ quote()


Quote a value: Quote a value:


:: .. code-block:: php
<?php <?php
$quoted = $conn->quote('value'); $quoted = $conn->quote('value');
Expand All @@ -193,7 +193,7 @@ quoteIdentifier()


Quote an identifier according to the platform details. Quote an identifier according to the platform details.


:: .. code-block:: php
<?php <?php
$quoted = $conn->quoteIdentifier('id'); $quoted = $conn->quoteIdentifier('id');
Expand Down
2 changes: 1 addition & 1 deletion reference/en/events.rst → en/reference/events.rst
Expand Up @@ -32,7 +32,7 @@ Doctrine is already shipped with two implementations for the
You can register events by subscribing them to the ``EventManager`` You can register events by subscribing them to the ``EventManager``
instance passed to the Connection factory: instance passed to the Connection factory:


:: .. code-block:: php
<?php <?php
$evm = new EventManager(); $evm = new EventManager();
Expand Down
Expand Up @@ -19,7 +19,7 @@ the ``Doctrine\Common`` and ``Doctrine\DBAL`` namespaces. Once you
have the Common and DBAL namespaces you must setup a class loader have the Common and DBAL namespaces you must setup a class loader
to be able to autoload the classes: to be able to autoload the classes:


:: .. code-block:: php
<?php <?php
use Doctrine\Common\ClassLoader; use Doctrine\Common\ClassLoader;
Expand Down
Expand Up @@ -105,15 +105,15 @@ OCI8: SQL Queries with Question Marks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


We had to implement a question mark to named parameter translation We had to implement a question mark to named parameter translation
inside the OCI8 DBAL Driver. This means that you cannot execute inside the OCI8 DBAL Driver. It works as a very simple parser with two states: Inside Literal, Outside Literal.
queries that contain question marks in the SQL string. For From our perspective it should be working in all cases, but you have to be careful with certain
example: queries:


.. code-block:: sql .. code-block:: sql
SELECT * FROM users WHERE name = 'bar?' SELECT * FROM users WHERE name = 'bar?'
Will be rewritten into: Could in case of a bug with the parser be rewritten into:


.. code-block:: sql .. code-block:: sql
Expand All @@ -123,17 +123,13 @@ For this reason you should always use prepared statements with
Oracle OCI8, never use string literals inside the queries. A query Oracle OCI8, never use string literals inside the queries. A query
for the user 'bar?' should look like: for the user 'bar?' should look like:


:: .. code-block:: php
$sql = 'SELECT * FROM users WHERE name = ?' $sql = 'SELECT * FROM users WHERE name = ?'
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->bindValue(1, 'bar?'); $stmt->bindValue(1, 'bar?');
$stmt->execute(); $stmt->execute();
We will probably fix this issue in the future by implementing a
little parser inside the OCI8 Driver that can detect the difference
between question mark needles and literal questions marks.

OCI-LOB instances OCI-LOB instances
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~


Expand Down
File renamed without changes.

0 comments on commit 9d60a95

Please sign in to comment.