diff --git a/reference/pdo/functions/PDO-beginTransaction.xml b/reference/pdo/functions/PDO-beginTransaction.xml index f9f9f3873a..97c4932568 100644 --- a/reference/pdo/functions/PDO-beginTransaction.xml +++ b/reference/pdo/functions/PDO-beginTransaction.xml @@ -1,49 +1,48 @@ - - - - - PDO::beginTransaction - - Initiates a transaction - - + + + + PDO::beginTransaction + + Initiates a transaction + + - - &reftitle.description; - - boolPDO::beginTransaction - - + + &reftitle.description; + + boolPDO::beginTransaction + + + + Turns off autocommit mode. While autocommit mode is turned off, changes + made to the database via the PDO object instance are not committed until + you end the transaction by calling PDO::commit. + Calling PDO::rollback will roll back all changes to + the database and return the connection to autocommit mode. + + + Some databases, including MySQL, automatically issue an implicit + COMMIT when a database definition language (DDL) statement such as + DROP TABLE or CREATE TABLE is issued within a transaction. The implicit + COMMIT will prevent you from rolling back any other changes within the + transaction boundary. + + + + + + &reftitle.examples; + + Roll back a transaction - Turns off autocommit mode. While autocommit mode is turned off, changes - made to the database via the PDO object instance are not committed until - you end the transaction by calling PDO::commit. - Calling PDO::rollback will roll back all changes to - the database and return the connection to autocommit mode. + The following example begins a transaction and issues two statements + that modify the database before rolling back the changes. On MySQL, + however, the DROP TABLE statement automatically commits the + transaction so that none of the changes in the transaction are rolled + back. - - Some databases, including MySQL, automatically issue an implicit - COMMIT when a database definition language (DDL) statement such as - DROP TABLE or CREATE TABLE is issued within a transaction. The implicit - COMMIT will prevent you from rolling back any other changes within the - transaction boundary. - - - - - - &reftitle.examples; - - Roll back a transaction - - The following example begins a transaction and issues two statements - that modify the database before rolling back the changes. On MySQL, - however, the DROP TABLE statement automatically commits the - transaction so that none of the changes in the transaction are rolled - back. - - + rollBack(); /* Database connection is now back in autocommit mode */ ?> ]]> - - - - + + + + - - &reftitle.seealso; - - - PDO::commit - PDO::rollBack - - - + + &reftitle.seealso; + + + PDO::commit + PDO::rollBack + + + - + - - - - PDO::commit - - Commits a transaction - - + + + + PDO::commit + + Commits a transaction + + - - &reftitle.description; - - boolPDO::commit - - - - Commits a transaction, returning the database connection to autocommit - mode until the next call to PDO::beginTransaction - starts a new transaction. - - + + &reftitle.description; + + boolPDO::commit + + + + Commits a transaction, returning the database connection to autocommit + mode until the next call to PDO::beginTransaction + starts a new transaction. + + - - &reftitle.examples; - - Commit a transaction - + + &reftitle.examples; + + Commit a transaction + commit(); /* Database connection is now back in autocommit mode */ ?> ]]> - - - - + + + + - - &reftitle.seealso; - - - PDO::beginTransaction - PDO::rollBack - - - + + &reftitle.seealso; + + + PDO::beginTransaction + PDO::rollBack + + + - + - - - PDO::__construct - - Creates a PDO instance representing a connection to a database - - - - &reftitle.description; - - PDOPDO::__construct - stringdsn - stringusername - stringpassword - arraydriver_options - - - Creates a PDO instance to represent a connection to the requested - database. - - - - &reftitle.parameters; - - - dsn - - - The Data Source Name, or DSN, contains the information required to - connect to the database. - - - In general, a DSN consists of the PDO driver name, followed by a colon, - followed by the PDO driver-specific connection syntax. Further - information is available from the PDO - driver-specific documentation. - - - The dsn parameter supports three - different methods of specifying the arguments required to create - a database connection: - - - - Driver invocation - - - dsn contains the full DSN. - - - - URI invocation - - - dsn consists of uri: - followed by a URI that defines the location of a file containing - the DSN string. The URI can specify a local file or a remote URL. - - uri:file:///path/to/dsnfile - - - Aliasing - - - dsn consists of a name - name that maps to - pdo.dsn.name in &php.ini; - defining the DSN string. - - - - The alias must be defined in &php.ini;, and not &htaccess; or &httpd.conf; - - - - - - - - - username - - - The user name for the DSN string. This parameter is optional for - some PDO drivers. - - - - password - - - The password for the DSN string. This parameter is optional for - some PDO drivers. - - - - driver_options - - - A key=>value array of driver-specific connection options. - - - - - - + + + + PDO::__construct + + Creates a PDO instance representing a connection to a database + + + + &reftitle.description; + + PDOPDO::__construct + stringdsn + stringusername + stringpassword + arraydriver_options + + + Creates a PDO instance to represent a connection to the requested + database. + + + + &reftitle.parameters; + + + dsn + + + The Data Source Name, or DSN, contains the information required to + connect to the database. + + + In general, a DSN consists of the PDO driver name, followed by a colon, + followed by the PDO driver-specific connection syntax. Further + information is available from the PDO + driver-specific documentation. + + + The dsn parameter supports three + different methods of specifying the arguments required to create + a database connection: + + + + Driver invocation + + + dsn contains the full DSN. + + + + URI invocation + + + dsn consists of uri: + followed by a URI that defines the location of a file containing + the DSN string. The URI can specify a local file or a remote URL. + + uri:file:///path/to/dsnfile + + + Aliasing + + + dsn consists of a name + name that maps to + pdo.dsn.name in &php.ini; + defining the DSN string. + + + + The alias must be defined in &php.ini;, and not &htaccess; or &httpd.conf; + + + + + + + + + username + + + The user name for the DSN string. This parameter is optional for + some PDO drivers. + + + + password + + + The password for the DSN string. This parameter is optional for + some PDO drivers. + + + + driver_options + + + A key=>value array of driver-specific connection options. + + + + + + - - &reftitle.returnvalues; - - Returns a PDO object on success. - - + + &reftitle.returnvalues; + + Returns a PDO object on success. + + - - &reftitle.errors; - - PDO::construct throws a PDOException if the attempt - to connect to the requested database fails. - - + + &reftitle.errors; + + PDO::construct throws a PDOException if the attempt + to connect to the requested database fails. + + - - &reftitle.examples; - - Create a PDO instance via driver invocation - + + &reftitle.examples; + + Create a PDO instance via driver invocation + ]]> - - - Create a PDO instance via URI invocation - - The following example assumes that the file - /usr/local/dbconnect exists with file permissions - that enable PHP to read the file. The file contains the PDO DSN to - connect to a DB2 database through the PDO_ODBC driver: - - + + + Create a PDO instance via URI invocation + + The following example assumes that the file + /usr/local/dbconnect exists with file permissions + that enable PHP to read the file. The file contains the PDO DSN to + connect to a DB2 database through the PDO_ODBC driver: + + - - - The PHP script can then create a database connection by simply - passing the uri: parameter and pointing to - the file URI: - - + + + The PHP script can then create a database connection by simply + passing the uri: parameter and pointing to + the file URI: + + ]]> - - - Create a PDO instance using an alias - - The following example assumes that &php.ini; contains the following - entry to enable a connection to a MySQL database using only the - alias mydb: - + + + Create a PDO instance using an alias + + The following example assumes that &php.ini; contains the following + entry to enable a connection to a MySQL database using only the + alias mydb: + [PDO] pdo.dsn.mydb="mysql:dbname=testdb;host=localhost" - - - + + + getMessage(); } ?> ]]> - - - - - + + + + + - - - - PDO::errorCode - - Fetch the SQLSTATE associated with the last operation on the database handle - - - - &reftitle.description; - - stringPDO::errorCode - - + + + + PDO::errorCode + + Fetch the SQLSTATE associated with the last operation on the database handle + + + + &reftitle.description; + + stringPDO::errorCode + + - + - - &reftitle.returnvalues; - - Returns a SQLSTATE, a five-character alphanumeric identifier defined in - the ANSI SQL-92 standard. Briefly, an SQLSTATE consists of a - two-character class value followed by a three-character subclass value. A - class value of 01 indicates a warning and is accompanied by a return code - of SQL_SUCCESS_WITH_INFO. Class values other than '01', except for the - class 'IM', indicate an error. The class 'IM' is specific to warnings - and errors that derive from the implementation of PDO (or perhaps ODBC, - if you're using the ODBC driver) itself. The subclass value '000' in any - class indicates that there is no subclass for that SQLSTATE. - - - PDO::errorCode only retrieves error codes for operations - performed directly on the database handle. If you create a PDOStatement - object through PDO::prepare or - PDO::query and invoke an error on the statement - handle, PDO::errorCode will not reflect that error. - You must call PDOStatement::errorCode to return the error - code for an operation performed on a particular statement handle. - - + + &reftitle.returnvalues; + + Returns a SQLSTATE, a five-character alphanumeric identifier defined in + the ANSI SQL-92 standard. Briefly, an SQLSTATE consists of a + two-character class value followed by a three-character subclass value. A + class value of 01 indicates a warning and is accompanied by a return code + of SQL_SUCCESS_WITH_INFO. Class values other than '01', except for the + class 'IM', indicate an error. The class 'IM' is specific to warnings + and errors that derive from the implementation of PDO (or perhaps ODBC, + if you're using the ODBC driver) itself. The subclass value '000' in any + class indicates that there is no subclass for that SQLSTATE. + + + PDO::errorCode only retrieves error codes for operations + performed directly on the database handle. If you create a PDOStatement + object through PDO::prepare or + PDO::query and invoke an error on the statement + handle, PDO::errorCode will not reflect that error. + You must call PDOStatement::errorCode to return the error + code for an operation performed on a particular statement handle. + + - - &reftitle.examples; - - Retrieving a SQLSTATE code - + + &reftitle.examples; + + Retrieving a SQLSTATE code + errorCode(); ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - - + + + + - - &reftitle.seealso; - - - PDO::errorInfo - PDOStatement::errorCode - PDOStatement::errorInfo - - - + + &reftitle.seealso; + + + PDO::errorInfo + PDOStatement::errorCode + PDOStatement::errorInfo + + + - + - - - - PDO::errorInfo - - Fetch extended error information associated with the last operation on the database handle - - - - &reftitle.description; - - arrayPDO::errorInfo - - + + + + PDO::errorInfo + + Fetch extended error information associated with the last operation on the database handle + + + + &reftitle.description; + + arrayPDO::errorInfo + + - + - - &reftitle.returnvalues; - - PDO::errorInfo returns an array of error information - about the last operation performed by this database handle. The array - consists of the following fields: - - - - - Element - Information - - - - - 0 - SQLSTATE error code (a five-character alphanumeric identifier defined - in the ANSI SQL standard). - - - 1 - Driver-specific error code. - - - 2 - Driver-specific error message. - - - - - + + &reftitle.returnvalues; + + PDO::errorInfo returns an array of error information + about the last operation performed by this database handle. The array + consists of the following fields: + + + + + Element + Information + + + + + 0 + SQLSTATE error code (a five-character alphanumeric identifier defined + in the ANSI SQL standard). + + + 1 + Driver-specific error code. + + + 2 + Driver-specific error message. + + + + + - - PDO::errorInfo only retrieves error information for - operations performed directly on the database handle. If you create a - PDOStatement object through PDO::prepare or - PDO::query and invoke an error on the statement - handle, PDO::errorInfo will not reflect the error - from the statement handle. You must call - PDOStatement::errorInfo to return the error - information for an operation performed on a particular statement handle. - - + + PDO::errorInfo only retrieves error information for + operations performed directly on the database handle. If you create a + PDOStatement object through PDO::prepare or + PDO::query and invoke an error on the statement + handle, PDO::errorInfo will not reflect the error + from the statement handle. You must call + PDOStatement::errorInfo to return the error + information for an operation performed on a particular statement handle. + + - - &reftitle.examples; - - Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database - + + &reftitle.examples; + + Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database + errorInfo()); ?> ]]> - - &example.outputs; - + + &example.outputs; + [IBM][CLI Driver][DB2/LINUX] SQL0204N "DANIELS.BONES" is an undefined name. SQLSTATE=42704 ) ]]> - - - - + + + + - - &reftitle.seealso; - - - PDO::errorCode - PDOStatement::errorCode - PDOStatement::errorInfo - - - + + &reftitle.seealso; + + + PDO::errorCode + PDOStatement::errorCode + PDOStatement::errorInfo + + + - + - + PDO::exec diff --git a/reference/pdo/functions/PDO-getAttribute.xml b/reference/pdo/functions/PDO-getAttribute.xml index 1943819bfd..e08896f043 100644 --- a/reference/pdo/functions/PDO-getAttribute.xml +++ b/reference/pdo/functions/PDO-getAttribute.xml @@ -1,6 +1,5 @@ - - + PDO::getAttribute diff --git a/reference/pdo/functions/PDO-getAvailableDrivers.xml b/reference/pdo/functions/PDO-getAvailableDrivers.xml index af198f6b1f..004265431a 100644 --- a/reference/pdo/functions/PDO-getAvailableDrivers.xml +++ b/reference/pdo/functions/PDO-getAvailableDrivers.xml @@ -1,6 +1,5 @@ - - + PDO::getAvailableDrivers diff --git a/reference/pdo/functions/PDO-lastInsertId.xml b/reference/pdo/functions/PDO-lastInsertId.xml index f516f5b10b..d7980e1c7e 100644 --- a/reference/pdo/functions/PDO-lastInsertId.xml +++ b/reference/pdo/functions/PDO-lastInsertId.xml @@ -1,104 +1,72 @@ - - - - - PDO::lastInsertId - - Returns the ID of the last inserted row or sequence value - - - - Description - - stringPDO::lastInsertId - stringname - + + + + PDO::lastInsertId + + Returns the ID of the last inserted row or sequence value + + + + &reftitle.description; + + stringPDO::lastInsertId + stringname + - - Returns the ID of the last inserted row, or the last value from a - sequence object, depending on the underlying driver. For example, - PDO_PGSQL requires you to specify the name of - a sequence object for the name parameter. - - - - This method may not return a meaningful or consistent result across - different PDO drivers, because the underlying database may not even - support the notion of auto-increment fields or sequences. - - - + + Returns the ID of the last inserted row, or the last value from a + sequence object, depending on the underlying driver. For example, + PDO_PGSQL requires you to specify the name of + a sequence object for the name parameter. + + + + This method may not return a meaningful or consistent result across + different PDO drivers, because the underlying database may not even + support the notion of auto-increment fields or sequences. + + + - - &reftitle.parameters; - - - - name - - - Name of the sequence object from which the ID should be returned. - - - - - - - - - &reftitle.returnvalues; - - If a sequence name was not specified for the name - parameter, PDOStatement::lastInsertId returns a - string representing the row ID of the last row that was inserted into - the database. - - - If a sequence name was specified for the name - parameter, PDOStatement::lastInsertId returns a - string representing the last value retrieved from the specified sequence - object. - - - If the PDO driver does not support this capability, - PDO::lastInsertID triggers an - IM001 SQLSTATE. - - - - + + + + + - + + &reftitle.returnvalues; + + If a sequence name was not specified for the name + parameter, PDOStatement::lastInsertId returns a + string representing the row ID of the last row that was inserted into + the database. + + + If a sequence name was specified for the name + parameter, PDOStatement::lastInsertId returns a + string representing the last value retrieved from the specified sequence + object. + + + If the PDO driver does not support this capability, + PDO::lastInsertID triggers an + IM001 SQLSTATE. + + + + - - - - PDO::prepare - - Prepares a statement for execution and returns a statement object - - - - &reftitle.description; - - PDOStatementPDO::prepare - stringstatement - arraydriver_options - + + + + PDO::prepare + + Prepares a statement for execution and returns a statement object + + + + &reftitle.description; + + PDOStatementPDO::prepare + stringstatement + arraydriver_options + - - Prepares an SQL statement to be executed by the - PDOStatement::execute method. The SQL statement can - contain zero or more named (:name) or question mark (?) parameter markers - for which real values will be substituted when the statement is executed. - You cannot use both named and question mark parameter markers within the same - SQL statement; pick one or the other parameter style. - - - You must include a unique parameter marker for each value you wish to pass - in to the statement when you call PDOStatement::execute. - You cannot use a named parameter marker of the same name twice in a prepared - statement. You cannot bind multiple values to a single named parameter in, - for example, the IN() clause of an SQL statement. - - - Calling PDO::prepare and - PDOStatement::execute for statements that will be - issued multiple times with different parameter values optimizes the - performance of your application by allowing the driver to negotiate - client and/or server side caching of the query plan and meta information, - and helps to prevent SQL injection attacks by eliminating the need to - manually quote the parameters. - - - PDO will emulate prepared statements/bound parameters for drivers that do - not natively support them, and can also rewrite named or question mark - style parameter markers to something more appropriate, if the driver - supports one style but not the other. - - - - &reftitle.parameters; - - - - statement - - - This must be a valid SQL statement for the target database server. - - - - - driver_options - - - This array holds one or more key=>value pairs to set - attribute values for the PDOStatement object that this method - returns. You would most commonly use this to set the - PDO::ATTR_CURSOR value to - PDO::CURSOR_SCROLL to request a scrollable cursor. - Some drivers have driver specific options that may be set at - prepare-time. - - - - - - + + Prepares an SQL statement to be executed by the + PDOStatement::execute method. The SQL statement can + contain zero or more named (:name) or question mark (?) parameter markers + for which real values will be substituted when the statement is executed. + You cannot use both named and question mark parameter markers within the same + SQL statement; pick one or the other parameter style. + + + You must include a unique parameter marker for each value you wish to pass + in to the statement when you call PDOStatement::execute. + You cannot use a named parameter marker of the same name twice in a prepared + statement. You cannot bind multiple values to a single named parameter in, + for example, the IN() clause of an SQL statement. + + + Calling PDO::prepare and + PDOStatement::execute for statements that will be + issued multiple times with different parameter values optimizes the + performance of your application by allowing the driver to negotiate + client and/or server side caching of the query plan and meta information, + and helps to prevent SQL injection attacks by eliminating the need to + manually quote the parameters. + + + PDO will emulate prepared statements/bound parameters for drivers that do + not natively support them, and can also rewrite named or question mark + style parameter markers to something more appropriate, if the driver + supports one style but not the other. + + + + &reftitle.parameters; + + + + statement + + + This must be a valid SQL statement for the target database server. + + + + + driver_options + + + This array holds one or more key=>value pairs to set + attribute values for the PDOStatement object that this method + returns. You would most commonly use this to set the + PDO::ATTR_CURSOR value to + PDO::CURSOR_SCROLL to request a scrollable cursor. + Some drivers have driver specific options that may be set at + prepare-time. + + + + + + - - &reftitle.returnvalues; - - If the database server successfully prepares the statement, - PDO::prepare returns a PDOStatement object. - If the database server cannot successfully prepare the statement, - PDO::prepare returns &false;. - - + + &reftitle.returnvalues; + + If the database server successfully prepares the statement, + PDO::prepare returns a PDOStatement object. + If the database server cannot successfully prepare the statement, + PDO::prepare returns &false;. + + - - &reftitle.examples; - - Prepare an SQL statement with named parameters - + + &reftitle.examples; + + Prepare an SQL statement with named parameters + execute(array(':calories' => 175, ':colour' => 'yellow')); $yellow = $sth->fetchAll(); ?> ]]> - - - - Prepare an SQL statement with question mark parameters - + + + + Prepare an SQL statement with question mark parameters + execute(array(175, 'yellow')); $yellow = $sth->fetchAll(); ?> ]]> - - - - + + + + - - &reftitle.seealso; - - - PDO::exec - PDO::query - PDOStatement::execute - - - - + + &reftitle.seealso; + + + PDO::exec + PDO::query + PDOStatement::execute + + + + - + PDO::query diff --git a/reference/pdo/functions/PDO-quote.xml b/reference/pdo/functions/PDO-quote.xml index 7665da8437..34afa01b25 100644 --- a/reference/pdo/functions/PDO-quote.xml +++ b/reference/pdo/functions/PDO-quote.xml @@ -1,6 +1,5 @@ - - + PDO::quote diff --git a/reference/pdo/functions/PDO-rollBack.xml b/reference/pdo/functions/PDO-rollBack.xml index 5f12359c02..2ed2d2c314 100644 --- a/reference/pdo/functions/PDO-rollBack.xml +++ b/reference/pdo/functions/PDO-rollBack.xml @@ -1,51 +1,50 @@ - - - - - PDO::rollBack - - Rolls back a transaction - - + + + + PDO::rollBack + + Rolls back a transaction + + - - &reftitle.description; - - boolPDO::rollBack - - + + &reftitle.description; + + boolPDO::rollBack + + - - Rolls back the current transaction, as initiated by - PDO::beginTransaction. It is an error to call this - method if no transaction is active. - - - If the database was set to autocommit mode, this function will restore - autocommit mode after it has rolled back the transaction. - - - Some databases, including MySQL, automatically issue an implicit - COMMIT when a database definition language (DDL) statement such as - DROP TABLE or CREATE TABLE is issued within a transaction. The implicit - COMMIT will prevent you from rolling back any other changes within the - transaction boundary. - - + + Rolls back the current transaction, as initiated by + PDO::beginTransaction. It is an error to call this + method if no transaction is active. + + + If the database was set to autocommit mode, this function will restore + autocommit mode after it has rolled back the transaction. + + + Some databases, including MySQL, automatically issue an implicit + COMMIT when a database definition language (DDL) statement such as + DROP TABLE or CREATE TABLE is issued within a transaction. The implicit + COMMIT will prevent you from rolling back any other changes within the + transaction boundary. + + - - &reftitle.examples; + + &reftitle.examples; + + Roll back a transaction - Roll back a transaction - - The following example begins a transaction and issues two statements - that modify the database before rolling back the changes. On MySQL, - however, the DROP TABLE statement automatically commits the - transaction so that none of the changes in the transaction are rolled - back. - - + The following example begins a transaction and issues two statements + that modify the database before rolling back the changes. On MySQL, + however, the DROP TABLE statement automatically commits the + transaction so that none of the changes in the transaction are rolled + back. + + rollBack(); /* Database connection is now back in autocommit mode */ ?> ]]> - - - - + + + + - - &reftitle.seealso; - - - PDO::beginTransaction - PDO::commit - - - + + &reftitle.seealso; + + + PDO::beginTransaction + PDO::commit + + + - + - - - - PDO::setAttribute - - Set an attribute - - - - Description - - boolPDO::setAttribute - intattribute - mixedvalue - + + + + PDO::setAttribute + + Set an attribute + + + + &reftitle.description; + + boolPDO::setAttribute + intattribute + mixedvalue + - - Sets an attribute on the database handle. Some of the available generic - attributes are listed below; some drivers may make use of - additional driver specific attributes. + + Sets an attribute on the database handle. Some of the available generic + attributes are listed below; some drivers may make use of + additional driver specific attributes. + + + PDO::ATTR_CASE: Force column names to a specific case. - PDO::ATTR_CASE: Force column names to a specific case. - - - PDO::CASE_LOWER: Force column names to lower case. - - - PDO::CASE_NATURAL: Leave column names as returned by - the database driver. - - - PDO::CASE_UPPER: Force column names to upper case. - - + PDO::CASE_LOWER: Force column names to lower case. - PDO::ATTR_ERRMODE: Error reporting. - - PDO::ERRMODE_SILENT: - Just set error codes. - PDO::ERRMODE_WARNING: - Raise E_WARNING. - PDO::ERRMODE_EXCEPTION: - Throw exceptions. - + + PDO::CASE_NATURAL: Leave column names as returned by + the database driver. - PDO::ATTR_ORACLE_NULLS - (available with all drivers, not just Oracle): - Conversion of NULL and empty strings. - - PDO::NULL_NATURAL: - No conversion. - PDO::NULL_EMPTY_STRING: - Empty string is converted to &null;. - PDO::NULL_TO_STRING: - NULL is converted to an empty string. - - - PDO::ATTR_STRINGIFY_FETCHES: - Convert numeric values to strings when fetching. - Requires bool. - - PDO::ATTR_STATEMENT_CLASS: - Set user-supplied statement class derived from PDOStatement. - Cannot be used with persistent PDO instances. - Requires array(string classname, array(mixed constructor_args)). - - PDO::ATTR_AUTOCOMMIT - (available in OCI, Firebird and MySQL): - Whether to autocommit every single statement. - - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY - (available in MySQL): - Use buffered queries. + + PDO::CASE_UPPER: Force column names to upper case. - - - + + PDO::ATTR_ERRMODE: Error reporting. + + PDO::ERRMODE_SILENT: + Just set error codes. + PDO::ERRMODE_WARNING: + Raise E_WARNING. + PDO::ERRMODE_EXCEPTION: + Throw exceptions. + + + PDO::ATTR_ORACLE_NULLS + (available with all drivers, not just Oracle): + Conversion of NULL and empty strings. + + PDO::NULL_NATURAL: + No conversion. + PDO::NULL_EMPTY_STRING: + Empty string is converted to &null;. + PDO::NULL_TO_STRING: + NULL is converted to an empty string. + + + PDO::ATTR_STRINGIFY_FETCHES: + Convert numeric values to strings when fetching. + Requires bool. + + PDO::ATTR_STATEMENT_CLASS: + Set user-supplied statement class derived from PDOStatement. + Cannot be used with persistent PDO instances. + Requires array(string classname, array(mixed constructor_args)). + + PDO::ATTR_AUTOCOMMIT + (available in OCI, Firebird and MySQL): + Whether to autocommit every single statement. + + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY + (available in MySQL): + Use buffered queries. + + + + + - - - - PDOStatement::bindColumn - - Bind a column to a PHP variable - - - - &reftitle.description; - - boolPDOStatement::bindColumn - mixedcolumn - mixedparam - inttype - + + + + PDOStatement::bindColumn + + Bind a column to a PHP variable + + + + &reftitle.description; + + boolPDOStatement::bindColumn + mixedcolumn + mixedparam + inttype + + + PDOStatement::bindColumn arranges to have a + particular variable bound to a given column in the result-set from a + query. Each call to PDOStatement::fetch or + PDOStatement::fetchAll will update all the variables + that are bound to columns. + + + + Since information about the columns is not always available to PDO until + the statement is executed, portable applications should call this + function after PDO::execute. + + + + + + &reftitle.parameters; + + + + column + + + Number of the column (1-indexed) or name of the column in the result set. + If using the column name, be aware that the name should match the + case of the column, as returned by the driver. + + + + + param + + + Name of the PHP variable to which the column will be bound. + + + + + type + + + Data type of the parameter, specified by the PDO::PARAM_* constants. + + + + + + + + + &reftitle.examples; + + + Binding result set output to PHP variables - PDOStatement::bindColumn arranges to have a - particular variable bound to a given column in the result-set from a - query. Each call to PDOStatement::fetch or - PDOStatement::fetchAll will update all the variables - that are bound to columns. + Binding columns in the result set to PHP variables is an effective + way to make the data contained in each row immediately available to + your application. The following example demonstrates how PDO allows + you to bind and retrieve columns with a variety of options and with + intelligent defaults. - - - Since information about the columns is not always available to PDO until - the statement is executed, portable applications should call this - function after PDO::execute. - - - - - - &reftitle.parameters; - - - - column - - - Number of the column (1-indexed) or name of the column in the result set. - If using the column name, be aware that the name should match the - case of the column, as returned by the driver. - - - - - param - - - Name of the PHP variable to which the column will be bound. - - - - - type - - - Data type of the parameter, specified by the PDO::PARAM_* constants. - - - - - - - - - &reftitle.examples; - - - Binding result set output to PHP variables - - Binding columns in the result set to PHP variables is an effective - way to make the data contained in each row immediately available to - your application. The following example demonstrates how PDO allows - you to bind and retrieve columns with a variety of options and with - intelligent defaults. - - - + ]]> - - &example.outputs; - - + &example.outputs; + + - - - - +]]> + + + + - - &reftitle.seealso; - - - PDOStatement::execute - PDOStatement::fetch - PDOStatement::fetchAll - PDOStatement::fetchColumn - - - + + &reftitle.seealso; + + + PDOStatement::execute + PDOStatement::fetch + PDOStatement::fetchAll + PDOStatement::fetchColumn + + + - + - - - - PDOStatement::bindParam - - Binds a parameter to the specified variable name - - - - &reftitle.description; - - boolPDOStatement::bindParam - mixedparameter - mixedvariable - intdata_type - intlength - mixeddriver_options - - - Binds a PHP variable to a corresponding named or question mark placeholder - in the SQL statement that was use to prepare the statement. Unlike - PDOStatement::bindValue, the variable is bound as a - reference and will only be evaluated at the time that - PDOStatement::execute is called. - - - Most parameters are input parameters, that is, parameters that are used - in a read-only fashion to build up the query. Some drivers support the - invocation of stored procedures that return data as output parameters, - and some also as input/output parameters that both send in data and are - updated to receive it. - + + + + PDOStatement::bindParam + + Binds a parameter to the specified variable name + + + + &reftitle.description; + + boolPDOStatement::bindParam + mixedparameter + mixedvariable + intdata_type + intlength + mixeddriver_options + + + Binds a PHP variable to a corresponding named or question mark placeholder + in the SQL statement that was use to prepare the statement. Unlike + PDOStatement::bindValue, the variable is bound as a + reference and will only be evaluated at the time that + PDOStatement::execute is called. + + + Most parameters are input parameters, that is, parameters that are used + in a read-only fashion to build up the query. Some drivers support the + invocation of stored procedures that return data as output parameters, + and some also as input/output parameters that both send in data and are + updated to receive it. + - + - - &reftitle.parameters; - - - - parameter - - - Parameter identifier. For a prepared statement using named - placeholders, this will be a parameter name of the form - :name. For a prepared statement using - question mark placeholders, this will be the 1-indexed position of - the parameter. - - - - - variable - - - Name of the PHP variable to bind to the SQL statement parameter. - - - - - data_type - - - Explicit data type for the parameter using the PDO::PARAM_* - constants. To return an INOUT parameter from a stored procedure, - use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits - for the data_type parameter. - - - - - length - - - Length of the data type. To indicate that a parameter is an OUT - parameter from a stored procedure, you must explicitly set the - length. - - - - - driver_options - - + + &reftitle.parameters; + + + + parameter + + + Parameter identifier. For a prepared statement using named + placeholders, this will be a parameter name of the form + :name. For a prepared statement using + question mark placeholders, this will be the 1-indexed position of + the parameter. + + + + + variable + + + Name of the PHP variable to bind to the SQL statement parameter. + + + + + data_type + + + Explicit data type for the parameter using the PDO::PARAM_* + constants. To return an INOUT parameter from a stored procedure, + use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits + for the data_type parameter. + + + + + length + + + Length of the data type. To indicate that a parameter is an OUT + parameter from a stored procedure, you must explicitly set the + length. + + + + + driver_options + + - - - - - - + + + + + + - - &reftitle.examples; - Execute a prepared statement with named placeholders - + + &reftitle.examples; + Execute a prepared statement with named placeholders + bindParam(':colour', $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> ]]> - - + + - Execute a prepared statement with question mark placeholders - + Execute a prepared statement with question mark placeholders + bindParam(2, $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> ]]> - - + + - Call a stored procedure with an INOUT parameter - + Call a stored procedure with an INOUT parameter + execute(); print("After pureeing fruit, the colour is: $colour"); ?> ]]> - - + + - + - - &reftitle.seealso; - - - PDO::prepare - PDOStatement::execute - PDOStatement::bindValue - - + + &reftitle.seealso; + + + PDO::prepare + PDOStatement::execute + PDOStatement::bindValue + + - - + + - - - - PDOStatement::bindValue - - Binds a value to a parameter - - - - &reftitle.description; - - boolPDOStatement::bindValue - mixedparameter - mixedvalue - intdata_type - - - Binds a value to a corresponding named or question mark placeholder - in the SQL statement that was use to prepare the statement. - - + + + + PDOStatement::bindValue + + Binds a value to a parameter + + + + &reftitle.description; + + boolPDOStatement::bindValue + mixedparameter + mixedvalue + intdata_type + + + Binds a value to a corresponding named or question mark placeholder + in the SQL statement that was use to prepare the statement. + + - - &reftitle.parameters; - - - - parameter - - - Parameter identifier. For a prepared statement using named - placeholders, this will be a parameter name of the form - :name. For a prepared statement using - question mark placeholders, this will be the 1-indexed position of - the parameter. - - - - - value - - - The value to bind to the parameter. - - - - - data_type - - - Explicit data type for the parameter using the PDO::PARAM_* - constants. - - - - - - + + &reftitle.parameters; + + + + parameter + + + Parameter identifier. For a prepared statement using named + placeholders, this will be a parameter name of the form + :name. For a prepared statement using + question mark placeholders, this will be the 1-indexed position of + the parameter. + + + + + value + + + The value to bind to the parameter. + + + + + data_type + + + Explicit data type for the parameter using the PDO::PARAM_* + constants. + + + + + + - - &reftitle.examples; - Execute a prepared statement with named placeholders - + + &reftitle.examples; + Execute a prepared statement with named placeholders + bindValue(':colour', $colour, PDO::PARAM_STR); $sth->execute(); ?> ]]> - - + + - Execute a prepared statement with question mark placeholders - + Execute a prepared statement with question mark placeholders + bindValue(2, $colour, PDO::PARAM_STR); $sth->execute(); ?> ]]> - - + + - + - - &reftitle.seealso; - - - PDO::prepare - PDOStatement::execute - PDOStatement::bindParam - - + + &reftitle.seealso; + + + PDO::prepare + PDOStatement::execute + PDOStatement::bindParam + + - - + + - + PDOStatement::closeCursor diff --git a/reference/pdo/functions/PDOStatement-columnCount.xml b/reference/pdo/functions/PDOStatement-columnCount.xml index 6de918634a..5d5a531189 100644 --- a/reference/pdo/functions/PDOStatement-columnCount.xml +++ b/reference/pdo/functions/PDOStatement-columnCount.xml @@ -1,6 +1,5 @@ - - + PDOStatement::columnCount diff --git a/reference/pdo/functions/PDOStatement-errorCode.xml b/reference/pdo/functions/PDOStatement-errorCode.xml index a2ca879f25..55c58e559e 100644 --- a/reference/pdo/functions/PDOStatement-errorCode.xml +++ b/reference/pdo/functions/PDOStatement-errorCode.xml @@ -1,35 +1,34 @@ - - - - - PDOStatement::errorCode - - Fetch the SQLSTATE associated with the last operation on the statement handle - - - - &reftitle.description; - - stringPDOStatement::errorCode - - - + + + + PDOStatement::errorCode + + Fetch the SQLSTATE associated with the last operation on the statement handle + + + + &reftitle.description; + + stringPDOStatement::errorCode + + + - - &reftitle.returnvalues; - - Identical to PDO::errorCode, except that - PDOStatement::errorCode only retrieves error codes - for operations performed with PDOStatement objects. - - + + &reftitle.returnvalues; + + Identical to PDO::errorCode, except that + PDOStatement::errorCode only retrieves error codes + for operations performed with PDOStatement objects. + + - - &reftitle.examples; - - Retrieving a SQLSTATE code - + + &reftitle.examples; + + Retrieving a SQLSTATE code + errorCode(); ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - - + + + + - - &reftitle.seealso; - - - PDO::errorCode - PDO::errorInfo - PDOStatement::errorInfo - - - + + &reftitle.seealso; + + + PDO::errorCode + PDO::errorInfo + PDOStatement::errorInfo + + + - + - - - - PDOStatement::errorInfo - - Fetch extended error information associated with the last operation on the statement handle - - - - &reftitle.description; - - arrayPDOStatement::errorInfo - - + + + + PDOStatement::errorInfo + + Fetch extended error information associated with the last operation on the statement handle + + + + &reftitle.description; + + arrayPDOStatement::errorInfo + + - + - - &reftitle.returnvalues; - - PDOStatement::errorInfo returns an array of - error information about the last operation performed by this - statement handle. The array consists of the following fields: - - - - - Element - Information - - - - - 0 - SQLSTATE error code (a five-character alphanumeric identifier defined - in the ANSI SQL standard). - - - 1 - Driver-specific error code. - - - 2 - Driver-specific error message. - - - - - - + + &reftitle.returnvalues; + + PDOStatement::errorInfo returns an array of + error information about the last operation performed by this + statement handle. The array consists of the following fields: + + + + + Element + Information + + + + + 0 + SQLSTATE error code (a five-character alphanumeric identifier defined + in the ANSI SQL standard). + + + 1 + Driver-specific error code. + + + 2 + Driver-specific error message. + + + + + + - - &reftitle.examples; - - Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database - + + &reftitle.examples; + + Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database + errorInfo(); print_r($arr); ?> ]]> - - &example.outputs; - + + &example.outputs; + [IBM][CLI Driver][DB2/LINUX] SQL0204N "DANIELS.BONES" is an undefined name. SQLSTATE=42704 ) ]]> - - - + + + - + - - &reftitle.seealso; - - - PDO::errorCode - PDO::errorInfo - PDOStatement::errorCode - - - + + &reftitle.seealso; + + + PDO::errorCode + PDO::errorInfo + PDOStatement::errorCode + + + - + - - - - PDOStatement::execute - - Executes a prepared statement - - - - &reftitle.description; - - boolPDOStatement::execute - arrayinput_parameters - - - Execute the prepared statement. If the prepared statement included - parameter markers, you must either: - - call PDOStatement::bindParam to bind PHP variables - to the parameter markers: bound variables pass their value as input and receive the - output value, if any, of their associated parameter markers - or pass an array of input-only parameter values - - - + + + + PDOStatement::execute + + Executes a prepared statement + + + + &reftitle.description; + + boolPDOStatement::execute + arrayinput_parameters + + + Execute the prepared statement. If the prepared statement included + parameter markers, you must either: + + call PDOStatement::bindParam to bind PHP variables + to the parameter markers: bound variables pass their value as input and receive the + output value, if any, of their associated parameter markers + or pass an array of input-only parameter values + + + - - &reftitle.parameters; - - - - input_parameters - - - An array of values with as many elements as there are bound - parameters in the SQL statement being executed. - - - You cannot bind multiple values to a single parameter; for example, - you cannot bind two values to a single named parameter in an IN() - clause. - - - - - - + + &reftitle.parameters; + + + + input_parameters + + + An array of values with as many elements as there are bound + parameters in the SQL statement being executed. + + + You cannot bind multiple values to a single parameter; for example, + you cannot bind two values to a single named parameter in an IN() + clause. + + + + + + - - &reftitle.returnvalues; - - &return.success; - - + + &reftitle.returnvalues; + + &return.success; + + - - &reftitle.examples; - Execute a prepared statement with bound variables - + + &reftitle.examples; + Execute a prepared statement with bound variables + bindParam(':colour', $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> ]]> - - + + - Execute a prepared statement with an array of insert values (named parameters) - + Execute a prepared statement with an array of insert values (named parameters) + prepare('SELECT name, colour, calories $sth->execute(array(':calories' => $calories, ':colour' => $colour)); ?> ]]> - - + + - Execute a prepared statement with an array of insert values (placeholders) - + Execute a prepared statement with an array of insert values (placeholders) + prepare('SELECT name, colour, calories $sth->execute(array($calories, $colour)); ?> ]]> - - + + - Execute a prepared statement with question mark placeholders - + Execute a prepared statement with question mark placeholders + bindParam(2, $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> ]]> - - - + + + - - &reftitle.seealso; - - - PDO::prepare - PDOStatement::bindParam - PDOStatement::fetch - PDOStatement::fetchAll - PDOStatement::fetchColumn - - - + + &reftitle.seealso; + + + PDO::prepare + PDOStatement::bindParam + PDOStatement::fetch + PDOStatement::fetchAll + PDOStatement::fetchColumn + + + - + - - - - PDOStatement::fetch - - Fetches the next row from a result set - - - - &reftitle.description; - - mixedPDOStatement::fetch - intfetch_style - intcursor_orientation - intcursor_offset - + + + + PDOStatement::fetch + + Fetches the next row from a result set + + + + &reftitle.description; + + mixedPDOStatement::fetch + intfetch_style + intcursor_orientation + intcursor_offset + - - Fetches a row from a result set associated with a PDOStatement object. The - fetch_style parameter determines how PDO returns - the row. - - + + Fetches a row from a result set associated with a PDOStatement object. The + fetch_style parameter determines how PDO returns + the row. + + - - &reftitle.parameters; - - - - fetch_style - - - Controls how the next row will be returned to the caller. This value - must be one of the PDO::FETCH_* constants, - defaulting to PDO::FETCH_BOTH. - - - PDO::FETCH_ASSOC: returns an array indexed by column - name as returned in your result set - - - PDO::FETCH_BOTH (default): returns an array indexed by - both column name and 0-indexed column number as returned in your - result set - - - PDO::FETCH_BOUND: returns &true; and assigns the - values of the columns in your result set to the PHP variables to which - they were bound with the PDOStatement::bindParam - method - - - PDO::FETCH_CLASS: returns a new instance of the - requested class, mapping the columns of the result set to named - properties in the class. If fetch_style - includes PDO::FETCH_CLASSTYPE (e.g. PDO::FETCH_CLASS | - PDO::FETCH_CLASSTYPE) then the name of the class is - determined from a value of the first column. - - - PDO::FETCH_INTO: updates an existing instance - of the requested class, mapping the columns of the result set to - named properties in the class - - - PDO::FETCH_LAZY: combines - PDO::FETCH_BOTH and PDO::FETCH_OBJ, - creating the object variable names as they are accessed - - - PDO::FETCH_NUM: returns an array indexed by column - number as returned in your result set, starting at column 0 - - - PDO::FETCH_OBJ: returns an anonymous object with - property names that correspond to the column names returned in your - result set - - - - - - - cursor_orientation - - - For a PDOStatement object representing a scrollable cursor, this - value determines which row will be returned to the caller. This value - must be one of the PDO::FETCH_ORI_* constants, - defaulting to PDO::FETCH_ORI_NEXT. To request a - scrollable cursor for your PDOStatement object, you must set the - PDO::ATTR_CURSOR attribute to - PDO::CURSOR_SCROLL when you prepare the SQL - statement with PDO::prepare. - - - - - offset - - - For a PDOStatement object representing a scrollable cursor for which - the cursor_orientation parameter is set to - PDO::FETCH_ORI_ABS, this value specifies the - absolute number of the row in the result set that shall be fetched. - - - For a PDOStatement object representing a scrollable cursor for which - the cursor_orientation parameter is set to - PDO::FETCH_ORI_REL, this value specifies the - row to fetch relative to the cursor position before - PDOStatement::fetch was called. - - - - - - + + &reftitle.parameters; + + + + fetch_style + + + Controls how the next row will be returned to the caller. This value + must be one of the PDO::FETCH_* constants, + defaulting to PDO::FETCH_BOTH. + + + PDO::FETCH_ASSOC: returns an array indexed by column + name as returned in your result set + + + PDO::FETCH_BOTH (default): returns an array indexed by + both column name and 0-indexed column number as returned in your + result set + + + PDO::FETCH_BOUND: returns &true; and assigns the + values of the columns in your result set to the PHP variables to which + they were bound with the PDOStatement::bindParam + method + + + PDO::FETCH_CLASS: returns a new instance of the + requested class, mapping the columns of the result set to named + properties in the class. If fetch_style + includes PDO::FETCH_CLASSTYPE (e.g. PDO::FETCH_CLASS | + PDO::FETCH_CLASSTYPE) then the name of the class is + determined from a value of the first column. + + + PDO::FETCH_INTO: updates an existing instance + of the requested class, mapping the columns of the result set to + named properties in the class + + + PDO::FETCH_LAZY: combines + PDO::FETCH_BOTH and PDO::FETCH_OBJ, + creating the object variable names as they are accessed + + + PDO::FETCH_NUM: returns an array indexed by column + number as returned in your result set, starting at column 0 + + + PDO::FETCH_OBJ: returns an anonymous object with + property names that correspond to the column names returned in your + result set + + + PDO::FETCH_SERIALIZE: returns an anonymous object with + property names that correspond to the column names returned in your + result set + + + + + + + cursor_orientation + + + For a PDOStatement object representing a scrollable cursor, this + value determines which row will be returned to the caller. This value + must be one of the PDO::FETCH_ORI_* constants, + defaulting to PDO::FETCH_ORI_NEXT. To request a + scrollable cursor for your PDOStatement object, you must set the + PDO::ATTR_CURSOR attribute to + PDO::CURSOR_SCROLL when you prepare the SQL + statement with PDO::prepare. + + + + + offset + + + For a PDOStatement object representing a scrollable cursor for which + the cursor_orientation parameter is set to + PDO::FETCH_ORI_ABS, this value specifies the + absolute number of the row in the result set that shall be fetched. + + + For a PDOStatement object representing a scrollable cursor for which + the cursor_orientation parameter is set to + PDO::FETCH_ORI_REL, this value specifies the + row to fetch relative to the cursor position before + PDOStatement::fetch was called. + + + + + + - - &reftitle.examples; - - Fetching rows using different fetch styles - + + &reftitle.examples; + + Fetching rows using different fetch styles + prepare("SELECT name, colour FROM fruit"); @@ -155,9 +159,9 @@ print $result->NAME; print("\n"); ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - Fetching rows with a scrollable cursor - + + + Fetching rows with a scrollable cursor + ]]> - - &example.outputs; - + + &example.outputs; + - - + + - - + + - - &reftitle.seealso; - - - PDO::query - PDOStatement::fetchAll - PDOStatement::fetchColumn - PDOStatement::prepare - PDOStatement::setFetchMode - - - - + + &reftitle.seealso; + + + PDO::query + PDOStatement::fetchAll + PDOStatement::fetchColumn + PDOStatement::prepare + PDOStatement::setFetchMode + + + + - - - - PDOStatement::fetchAll - - Returns an array containing all of the result set rows - - - - &reftitle.description; - - arrayPDOStatement::fetchAll - intfetch_style - intcolumn_index - + + + + PDOStatement::fetchAll + + Returns an array containing all of the result set rows + + + + &reftitle.description; + + arrayPDOStatement::fetchAll + intfetch_style + intcolumn_index + - + - - &reftitle.parameters; - - - - fetch_style - - - Controls the contents of the returned array as documented in - PDOStatement::fetch. Defaults to - PDO::FETCH_BOTH. - - - To return an array consisting of all values of a single column from - the result set, specify PDO::FETCH_COLUMN. You - can specify which column you want with the - column-index parameter. - - - To fetch only the unique values of a single column from the result set, - bitwise-OR PDO::FETCH_COLUMN with - PDO::FETCH_UNIQUE. - - - To return an associative array grouped by the values of a specified - column, bitwise-OR PDO::FETCH_COLUMN with - PDO::FETCH_GROUP. - - - - - column_index - - - Returns the indicated 0-indexed column when the value of - fetch_style is - PDO::FETCH_COLUMN. Defaults to 0. - - - - - - + + &reftitle.parameters; + + + + fetch_style + + + Controls the contents of the returned array as documented in + PDOStatement::fetch. Defaults to + PDO::FETCH_BOTH. + + + To return an array consisting of all values of a single column from + the result set, specify PDO::FETCH_COLUMN. You + can specify which column you want with the + column-index parameter. + + + To fetch only the unique values of a single column from the result set, + bitwise-OR PDO::FETCH_COLUMN with + PDO::FETCH_UNIQUE. + + + To return an associative array grouped by the values of a specified + column, bitwise-OR PDO::FETCH_COLUMN with + PDO::FETCH_GROUP. + + + + + column_index + + + Returns the indicated 0-indexed column when the value of + fetch_style is + PDO::FETCH_COLUMN. Defaults to 0. + + + + + + - - &reftitle.returnvalues; - - PDOStatement::fetchAll returns an array containing - all of the remaining rows in the result set. The array represents each - row as either an array of column values or an object with properties - corresponding to each column name. - - - Using this method to fetch large result sets will result in a heavy - demand on system and possibly network resources. Rather than retrieving - all of the data and manipulating it in PHP, consider using the database - server to manipulate the result sets. For example, use the WHERE and - SORT BY clauses in SQL to restrict results before retrieving and - processing them with PHP. - - + + &reftitle.returnvalues; + + PDOStatement::fetchAll returns an array containing + all of the remaining rows in the result set. The array represents each + row as either an array of column values or an object with properties + corresponding to each column name. + + + Using this method to fetch large result sets will result in a heavy + demand on system and possibly network resources. Rather than retrieving + all of the data and manipulating it in PHP, consider using the database + server to manipulate the result sets. For example, use the WHERE and + SORT BY clauses in SQL to restrict results before retrieving and + processing them with PHP. + + - - &reftitle.examples; - - Fetch all remaining rows in a result set - + + &reftitle.examples; + + Fetch all remaining rows in a result set + prepare("SELECT name, colour FROM fruit"); @@ -96,9 +95,9 @@ $result = $sth->fetchAll(); print_r($result); ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - Fetching all values of a single column from a result set - - The following example demonstrates how to return all of the values of a - single column from a result set, even though the SQL statement itself - may return multiple columns per row. - - + + + Fetching all values of a single column from a result set + + The following example demonstrates how to return all of the values of a + single column from a result set, even though the SQL statement itself + may return multiple columns per row. + + prepare("SELECT name, colour FROM fruit"); @@ -140,9 +139,9 @@ $result = $sth->fetchAll(PDO::FETCH_COLUMN, 0); var_dump($result); ?> ]]> - - &example.outputs; - + + &example.outputs; + watermelon ) ]]> - - - Grouping all values by a single column - - The following example demonstrates how to return an associative array - grouped by the values of the specified column in the result set. The - array contains three keys: values apple and - pear are returned as arrays that contain two - different colours, while watermelon is - returned as an array that contains only one colour. - - + + + Grouping all values by a single column + + The following example demonstrates how to return an associative array + grouped by the values of the specified column in the result set. The + array contains three keys: values apple and + pear are returned as arrays that contain two + different colours, while watermelon is + returned as an array that contains only one colour. + + prepare("INSERT INTO fruit(name, colour) VALUES (?, ?)"); @@ -179,9 +178,9 @@ $sth->execute(); var_dump($sth->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); ?> ]]> - - &example.outputs; - + + &example.outputs; + @@ -206,25 +205,25 @@ array(3) { } ]]> - - + + - - + + - - &reftitle.seealso; - - - PDO::query - PDOStatement::fetch - PDOStatement::fetchColumn - PDOStatement::prepare - PDOStatement::setFetchMode - - - - + + &reftitle.seealso; + + + PDO::query + PDOStatement::fetch + PDOStatement::fetchColumn + PDOStatement::prepare + PDOStatement::setFetchMode + + + + - + PDOStatement::fetchColumn @@ -16,10 +15,10 @@ intcolumn_number - - Returns a single column from the next row of a result set or &false; if - there are no more rows. - + + Returns a single column from the next row of a result set or &false; if + there are no more rows. + diff --git a/reference/pdo/functions/PDOStatement-fetchObject.xml b/reference/pdo/functions/PDOStatement-fetchObject.xml index 72f8a27b58..58503f55d4 100644 --- a/reference/pdo/functions/PDOStatement-fetchObject.xml +++ b/reference/pdo/functions/PDOStatement-fetchObject.xml @@ -1,6 +1,5 @@ - - + PDOStatement::fetchObject diff --git a/reference/pdo/functions/PDOStatement-getAttribute.xml b/reference/pdo/functions/PDOStatement-getAttribute.xml index 2386026f6e..63e5cb2571 100644 --- a/reference/pdo/functions/PDOStatement-getAttribute.xml +++ b/reference/pdo/functions/PDOStatement-getAttribute.xml @@ -1,6 +1,5 @@ - - + PDOStatement::getAttribute diff --git a/reference/pdo/functions/PDOStatement-getColumnMeta.xml b/reference/pdo/functions/PDOStatement-getColumnMeta.xml index 8c9210f6af..1ffa220237 100644 --- a/reference/pdo/functions/PDOStatement-getColumnMeta.xml +++ b/reference/pdo/functions/PDOStatement-getColumnMeta.xml @@ -1,6 +1,5 @@ - - + PDOStatement::getColumnMeta diff --git a/reference/pdo/functions/PDOStatement-nextRowset.xml b/reference/pdo/functions/PDOStatement-nextRowset.xml index 88f24dbba9..c84d8a4b81 100644 --- a/reference/pdo/functions/PDOStatement-nextRowset.xml +++ b/reference/pdo/functions/PDOStatement-nextRowset.xml @@ -1,6 +1,5 @@ - - + PDOStatement::nextRowset diff --git a/reference/pdo/functions/PDOStatement-rowCount.xml b/reference/pdo/functions/PDOStatement-rowCount.xml index 7a84267df6..df0919780a 100644 --- a/reference/pdo/functions/PDOStatement-rowCount.xml +++ b/reference/pdo/functions/PDOStatement-rowCount.xml @@ -1,43 +1,42 @@ - - - - - PDOStatement::rowCount - - Returns the number of rows affected by the last SQL statement - - - - &reftitle.description; - - intPDOStatement::rowCount - - + + + + PDOStatement::rowCount + + Returns the number of rows affected by the last SQL statement + + + + &reftitle.description; + + intPDOStatement::rowCount + + + + PDOStatement::rowCount returns the number of + rows affected by the last DELETE, INSERT, or UPDATE statement + executed by the corresponding PDOStatement object. + + + If the last SQL statement executed by the associated + PDOStatement was a SELECT statement, some databases + may return the number of rows returned by that statement. However, this + behaviour is not guaranteed for all databases and should not be relied + on for portable applications. + + + + &reftitle.examples; + + + Return the number of deleted rows PDOStatement::rowCount returns the number of - rows affected by the last DELETE, INSERT, or UPDATE statement - executed by the corresponding PDOStatement object. + rows affected by a DELETE, INSERT, or UPDATE statement. - - If the last SQL statement executed by the associated - PDOStatement was a SELECT statement, some databases - may return the number of rows returned by that statement. However, this - behaviour is not guaranteed for all databases and should not be relied - on for portable applications. - - - - &reftitle.examples; - - - Return the number of deleted rows - - PDOStatement::rowCount returns the number of - rows affected by a DELETE, INSERT, or UPDATE statement. - - + rowCount(); print("Deleted $count rows.\n"); ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - - Counting rows returned by a SELECT statement - - For most databases, PDOStatement::rowCount does not - return the number of rows affected by a SELECT statement. Instead, use - PDO::query to issue a SELECT COUNT(*) statement - with the same predicates as your intended SELECT statement, then use - PDOStatement::fetchColumn to retrieve the number - of rows that will be returned. Your application can then perform the - correct action. - - + + + + Counting rows returned by a SELECT statement + + For most databases, PDOStatement::rowCount does not + return the number of rows affected by a SELECT statement. Instead, use + PDO::query to issue a SELECT COUNT(*) statement + with the same predicates as your intended SELECT statement, then use + PDOStatement::fetchColumn to retrieve the number + of rows that will be returned. Your application can then perform the + correct action. + + 100"; if ($res = $conn->query($sql)) { /* Check the number of rows that match the SELECT statement */ - if ($res->fetchColumn() > 0) { + if ($res->fetchColumn() > 0) { /* Issue the real SELECT statement and work with the results */ $sql = "SELECT name FROM fruit WHERE calories > 100"; - foreach ($conn->query($sql) as $row) { - print "Name: " . $row['NAME'] . "\n"; + foreach ($conn->query($sql) as $row) { + print "Name: " . $row['NAME'] . "\n"; } } /* No rows matched -- do something else */ - else { - print "No rows matched the query."; + else { + print "No rows matched the query."; } } @@ -94,32 +93,32 @@ $res = null; $conn = null; ?> ]]> - - &example.outputs; - + + &example.outputs; + - - + + - - - - &reftitle.seealso; - - - PDOStatement::columnCount - PDOStatement::fetchColumn - PDOStatement::query - - + + + + &reftitle.seealso; + + + PDOStatement::columnCount + PDOStatement::fetchColumn + PDOStatement::query + + - - + + - + PDOStatement::setAttribute diff --git a/reference/pdo/functions/PDOStatement-setFetchMode.xml b/reference/pdo/functions/PDOStatement-setFetchMode.xml index 50725c0991..b2122a69c2 100644 --- a/reference/pdo/functions/PDOStatement-setFetchMode.xml +++ b/reference/pdo/functions/PDOStatement-setFetchMode.xml @@ -1,6 +1,5 @@ - - + PDOStatement::setFetchMode