Update documentation to use the new fetch API

parent 256cefa6
...@@ -42,7 +42,7 @@ object is closed: ...@@ -42,7 +42,7 @@ object is closed:
<?php <?php
$stmt = $conn->executeCacheQuery($query, $params, $types, new QueryCacheProfile(0, "some key")); $stmt = $conn->executeCacheQuery($query, $params, $types, new QueryCacheProfile(0, "some key"));
$data = $stmt->fetchAll(); $data = $stmt->fetchAllAssociative();
$stmt->closeCursor(); // at this point the result is cached $stmt->closeCursor(); // at this point the result is cached
.. warning:: .. warning::
......
...@@ -41,7 +41,7 @@ the query until there are no more rows: ...@@ -41,7 +41,7 @@ the query until there are no more rows:
<?php <?php
while ($row = $stmt->fetch()) { while (($row = $stmt->fetchAssociative()) !== false) {
echo $row['headline']; echo $row['headline'];
} }
...@@ -308,7 +308,7 @@ Prepare a given SQL statement and return the ...@@ -308,7 +308,7 @@ Prepare a given SQL statement and return the
<?php <?php
$statement = $conn->prepare('SELECT * FROM user'); $statement = $conn->prepare('SELECT * FROM user');
$statement->execute(); $statement->execute();
$users = $statement->fetchAll(); $users = $statement->fetchAllAssociative();
/* /*
array( array(
...@@ -346,7 +346,7 @@ parameters to the execute method, then returning the statement: ...@@ -346,7 +346,7 @@ parameters to the execute method, then returning the statement:
<?php <?php
$statement = $conn->executeQuery('SELECT * FROM user WHERE username = ?', array('jwage')); $statement = $conn->executeQuery('SELECT * FROM user WHERE username = ?', array('jwage'));
$user = $statement->fetch(); $user = $statement->fetchAssociative();
/* /*
array( array(
...@@ -360,15 +360,15 @@ to perform necessary type conversions between actual input ...@@ -360,15 +360,15 @@ to perform necessary type conversions between actual input
parameters and expected database values. See the parameters and expected database values. See the
:ref:`Types <mappingMatrix>` section for more information. :ref:`Types <mappingMatrix>` section for more information.
fetchAll() fetchAllAssociative()
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Execute the query and fetch all results into an array: Execute the query and fetch all results into an array:
.. code-block:: php .. code-block:: php
<?php <?php
$users = $conn->fetchAll('SELECT * FROM user'); $users = $conn->fetchAllAssociative('SELECT * FROM user');
/* /*
array( array(
...@@ -379,15 +379,15 @@ Execute the query and fetch all results into an array: ...@@ -379,15 +379,15 @@ Execute the query and fetch all results into an array:
) )
*/ */
fetchArray() fetchNumeric()
~~~~~~~~~~~~ ~~~~~~~~~~~~~~
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 .. code-block:: php
<?php <?php
$user = $conn->fetchArray('SELECT * FROM user WHERE username = ?', array('jwage')); $user = $conn->fetchNumeric('SELECT * FROM user WHERE username = ?', array('jwage'));
/* /*
array( array(
...@@ -396,26 +396,26 @@ Numeric index retrieval of first result row of the given query: ...@@ -396,26 +396,26 @@ Numeric index retrieval of first result row of the given query:
) )
*/ */
fetchColumn() fetchOne()
~~~~~~~~~~~~~ ~~~~~~~~~~
Retrieve only the given column of the first result row. Retrieve only the value of the first column of the first result row.
.. code-block:: php .. code-block:: php
<?php <?php
$username = $conn->fetchColumn('SELECT username FROM user WHERE id = ?', array(1), 0); $username = $conn->fetchOne('SELECT username FROM user WHERE id = ?', array(1), 0);
echo $username; // jwage echo $username; // jwage
fetchAssoc() fetchAssociative()
~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Retrieve assoc row of the first result row. Retrieve associative array of the first result row.
.. code-block:: php .. code-block:: php
<?php <?php
$user = $conn->fetchAssoc('SELECT * FROM user WHERE username = ?', array('jwage')); $user = $conn->fetchAssociative('SELECT * FROM user WHERE username = ?', array('jwage'));
/* /*
array( array(
'username' => 'jwage', 'username' => 'jwage',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment