From 06748b6a718ee7124873eeb6503b871a6259371c Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 18 Jan 2005 03:16:39 +0000 Subject: [PATCH] Flesh out PDO::exec, add new files based on xml_proto skeletons. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@177507 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/pdo/functions/PDO-exec.xml | 123 +++++++++++--- reference/pdo/functions/PDO-getAttribute.xml | 112 +++++++++++++ reference/pdo/functions/PDO-query.xml | 119 ++++++++++++++ .../functions/PDOStatement-columnCount.xml | 116 +++++++++++++ .../functions/PDOStatement-getAttribute.xml | 110 +++++++++++++ .../functions/PDOStatement-getColumnMeta.xml | 145 +++++++++++++++++ .../functions/PDOStatement-setAttribute.xml | 154 ++++++++++++++++++ .../functions/PDOStatement-setFetchMode.xml | 145 +++++++++++++++++ reference/pdo/reference.xml | 34 +++- 9 files changed, 1036 insertions(+), 22 deletions(-) create mode 100644 reference/pdo/functions/PDO-getAttribute.xml create mode 100644 reference/pdo/functions/PDO-query.xml create mode 100644 reference/pdo/functions/PDOStatement-columnCount.xml create mode 100644 reference/pdo/functions/PDOStatement-getAttribute.xml create mode 100644 reference/pdo/functions/PDOStatement-getColumnMeta.xml create mode 100644 reference/pdo/functions/PDOStatement-setAttribute.xml create mode 100644 reference/pdo/functions/PDOStatement-setFetchMode.xml diff --git a/reference/pdo/functions/PDO-exec.xml b/reference/pdo/functions/PDO-exec.xml index 49a9919293..b7042414be 100644 --- a/reference/pdo/functions/PDO-exec.xml +++ b/reference/pdo/functions/PDO-exec.xml @@ -1,24 +1,109 @@ - - - - - - PDO::exec - - Execute a query that does not return a row set, returning the number of affected rows - - - - Description - - intPDO::exec - stringquery - + + + + + + PDO::exec + + Execute an SQL statement and return the number of affected rows + + + + &reftitle.description; + + longPDO::exec + stringstatement + - &warn.undocumented.func; + &warn.experimental.func; - - + + PDO::exec prepares and executes an SQL statement in + a single function call, returning the number of rows affected by the + statement. + + + PDO::exec does not return results from a SELECT + statement. For a SELECT statement that you only need to issue once + during your program, consider issuing PDO::query. + For a SELECT statement that you need to issue multiple times, prepare + a PDOStatement object with PDO::prepare and issue + the statement with PDOStatement::execute. + + + + + &reftitle.parameters; + + + + statement + + + The SQL statement to prepare and execute. + + + + + + + + &reftitle.returnvalues; + + PDO::exec returns the number of rows that were modified + or deleted by the SQL statement you issued. If no rows were affected, + PDO::exec returns 0. + + + + + &reftitle.examples; + + + Issuing a DELETE statement + + Count the number of rows deleted by a DELETE statement with no WHERE + clause. + + +exec("DELETE FROM fruit WHERE colour = 'red'"); + +/* Return number of rows that were deleted */ +print("Return number of rows that were deleted:\n"); +print("Deleted $count rows.\n"); +?> +]]> + + &example.outputs; + + + + + + + + + + &reftitle.seealso; + + + PDO::prepare + PDO::query + PDOStatement::execute + + + + + + + + + + PDO::getAttribute + + Retrive a database connection attribute + + + + &reftitle.description; + + mixedPDO::getAttribute + longattribute + + + &warn.undocumented.func; + + + + + + + + + + &reftitle.seealso; + + + PDO::setAttribute + PDOStatement::getAttribute + PDOStatement::setAttribute + + + + + + + + diff --git a/reference/pdo/functions/PDO-query.xml b/reference/pdo/functions/PDO-query.xml new file mode 100644 index 0000000000..ad8ae28b67 --- /dev/null +++ b/reference/pdo/functions/PDO-query.xml @@ -0,0 +1,119 @@ + + + + + + PDO::query + + Executes an SQL statement, returning a result set as a PDOStatement object + + + + &reftitle.description; + + objectPDO::query + stringstatement + + + &warn.experimental.func; + + + PDO::query prepares and executes an SQL statement in + a single function call, returning the result set (if any) returned by the + statement as a PDOStatement object. + + + For a SELECT statement that you need to issue multiple times, prepare + a PDOStatement object with PDO::prepare and issue + the statement with PDOStatement::execute. + + + + + &reftitle.parameters; + + + + statement + + + The SQL statement to prepare and execute. + + + + + + + + &reftitle.returnvalues; + + PDO::query returns a PDOStatement object. + + + + + + + + &reftitle.seealso; + + + PDO::exec + PDO::prepare + PDOStatement::execute + + + + + + + + diff --git a/reference/pdo/functions/PDOStatement-columnCount.xml b/reference/pdo/functions/PDOStatement-columnCount.xml new file mode 100644 index 0000000000..6c738d755b --- /dev/null +++ b/reference/pdo/functions/PDOStatement-columnCount.xml @@ -0,0 +1,116 @@ + + + + + + PDOStatement::columnCount + + Returns the number of columns in the result set + + + + &reftitle.description; + + intPDOStatement::columnCount + + + + &warn.experimental.func; + + Use PDOStatement::columnCount to return the number + of columns in the result set represented by the PDOStatement object. + + + If the PDOStatement object was returned from PDO::query, + the column count is immediately available. + + + If the PDOStatement object was returned from + PDO::prepare, an accurate column count will not be + available until you invoke PDOStatement::execute. + + + + + &reftitle.returnvalues; + + Returns the number of columns in the result set represented by the + PDOStatement object. If there is no result set, + PDOStatement::columnCount returns 0. + + + + + &reftitle.examples; + + + Counting columns + + This example demonstrates how PDOStatement::columnCount + operates with and without a result set. + + +prepare("SELECT name, colour FROM fruit"); + +/* Count the number of columns in the (non-existent) result set */ +$colcount = $sth->columnCount(); +print("Before execute(), result set has $colcount columns (should be 0)\n"); + +$sth->execute(); + +/* Count the number of columns in the result set */ +$colcount = $sth->columnCount(); +print("After execute(), result set has $colcount columns (should be 2)\n"); + +?> +]]> + + &example.outputs; + + + + + + + + + + &reftitle.seealso; + + + PDO::prepare + PDOStatement::execute + PDOStatement::rowCount + + + + + + + diff --git a/reference/pdo/functions/PDOStatement-getAttribute.xml b/reference/pdo/functions/PDOStatement-getAttribute.xml new file mode 100644 index 0000000000..8b84b183d2 --- /dev/null +++ b/reference/pdo/functions/PDOStatement-getAttribute.xml @@ -0,0 +1,110 @@ + + + + + + PDOStatement::getAttribute + + Retrieve a statement attribute + + + + &reftitle.description; + + mixedPDOStatement::getAttribute + longattribute + + + &warn.undocumented.func; + + + + + + + + + &reftitle.seealso; + + + PDO::getAttribute + PDO::setAttribute + PDOStatement::setAttribute + + + + + + + diff --git a/reference/pdo/functions/PDOStatement-getColumnMeta.xml b/reference/pdo/functions/PDOStatement-getColumnMeta.xml new file mode 100644 index 0000000000..952fcd49a0 --- /dev/null +++ b/reference/pdo/functions/PDOStatement-getColumnMeta.xml @@ -0,0 +1,145 @@ + + + + + + PDOStatement::getColumnMeta + + Returns meta data for a numbered column + + + + &reftitle.description; + + arrayPDOStatement::getColumnMeta + int$column + + + &warn.undocumented.func; + + + + &reftitle.parameters; + + + + $column + + + Its description + + + + + + + + &reftitle.returnvalues; + + What the function returns, first on success, then on failure. See + also the &return.success; entity + + + + + + + + + + + + + + + + + + diff --git a/reference/pdo/functions/PDOStatement-setAttribute.xml b/reference/pdo/functions/PDOStatement-setAttribute.xml new file mode 100644 index 0000000000..e5d214783f --- /dev/null +++ b/reference/pdo/functions/PDOStatement-setAttribute.xml @@ -0,0 +1,154 @@ + + + + + + PDOStatement::setAttribute + + Set a statement attribute + + + + &reftitle.description; + + boolPDOStatement::setAttribute + longattribute + mixedvalue + + + &warn.undocumented.func; + + + + + + + + + + + + + + + &reftitle.seealso; + + + PDO::getAttribute + PDO::setAttribute + PDOStatement::getAttribute + + + + + + + diff --git a/reference/pdo/functions/PDOStatement-setFetchMode.xml b/reference/pdo/functions/PDOStatement-setFetchMode.xml new file mode 100644 index 0000000000..e54ee76edf --- /dev/null +++ b/reference/pdo/functions/PDOStatement-setFetchMode.xml @@ -0,0 +1,145 @@ + + + + + + PDOStatement::setFetchMode + + Returns meta data for a numbered column + + + + &reftitle.description; + + boolPDOStatement::setFetchMode + intmode + + + &warn.undocumented.func; + + + + &reftitle.parameters; + + + + mode + + + Its description + + + + + + + + &reftitle.returnvalues; + + What the function returns, first on success, then on failure. See + also the &return.success; entity + + + + + + + + + + + + + + + + + + diff --git a/reference/pdo/reference.xml b/reference/pdo/reference.xml index 0bc2039de0..ab70299bd1 100644 --- a/reference/pdo/reference.xml +++ b/reference/pdo/reference.xml @@ -1,9 +1,9 @@ - + PDO Functions - pdo + PDO
@@ -133,7 +133,7 @@ extension=php_pdo.dll exec - issues an SQL - statement + statement and returns the number of affected rows errorCode - @@ -144,6 +144,10 @@ extension=php_pdo.dll retrieves an array of error information, if any, from the database + + getAttribute - + retrieves a database connection attribute + lastInsertId - retrieves the value of the last row that was inserted into a @@ -153,6 +157,10 @@ extension=php_pdo.dll prepare - prepares an SQL statement for execution + + query - issues an SQL + statement and returns a result set + rollBack - roll back a transaction @@ -179,6 +187,10 @@ extension=php_pdo.dll bindParam - binds a PHP variable to a parameter in the prepared statement + + columnCount - + returns the number of columns in the result set + errorCode - retrieves an error code, if any, from the statement @@ -203,10 +215,26 @@ extension=php_pdo.dll fetchSingle - returns the data from the first column in a result set + + getAttribute - + retrieves a PDOStatement attribute + + + getColumnMeta - + retrieves metadata for a column in the result set + rowCount - returns the number of rows that were affected by the execution of an SQL statement + + setAttribute - + sets a PDOStatement attribute + + + setFetchMode - + sets the fetch mode for a PDOStatement +