PHP PDO Predefined Constants
The following constants are defined by this extension module, so they are only valid when this extension's module is compiled into PHP or dynamically loaded at runtime.
Note: PDO uses class constants since PHP 5.1. Earlier versions used the global constant form PDO_PARAM_BOOL.
| PDO::PARAM_BOOL (integer) | Represents the boolean data type. |
|---|---|
| PDO::PARAM_NULL (integer) | Represents the NULL data type in SQL. |
| PDO::PARAM_INT (integer) | Represents the integer type in SQL. |
| PDO::PARAM_STR (integer) | Represents the CHAR, VARCHAR, or other string types in SQL. |
| PDO::PARAM_LOB (integer) | Represents the large object (LOB) data type in SQL. |
| PDO::PARAM_STMT (integer) | Represents a recordset type. Currently not supported by any driver. |
| PDO::PARAM_INPUT_OUTPUT (integer) | Specifies the parameter as an INOUT parameter of a stored procedure. Must be bitwise ORed with an explicit PDO::PARAM_* data type. |
| PDO::FETCH_LAZY (integer) | Specifies the fetch mode to return each row in the result set as an object whose variable names correspond to column names. PDO::FETCH_LAZY creates object variable names for access. Not valid in PDOStatement::fetchAll(). |
| PDO::FETCH_ASSOC (integer) | Specifies the fetch mode to return each row in the corresponding result set as an array indexed by column name. If the result set contains multiple columns with the same name, PDO::FETCH_ASSOC returns only one value per column name. |
| PDO::FETCH_NAMED (integer) | Specifies the fetch mode to return each row in the corresponding result set as an array indexed by column name. If the result set contains multiple columns with the same name, PDO::FETCH_ASSOC returns an array containing values for each column name. |
| PDO::FETCH_NUM (integer) | Specifies the fetch mode to return each row in the corresponding result set as an array indexed by column number, starting from column 0. |
| PDO::FETCH_BOTH (integer) | Specifies the fetch mode to return each row in the corresponding result set as an array indexed by both column number and column name, starting from column 0. |
| PDO::FETCH_OBJ (integer) | Specifies the fetch mode to return each row in the result set as an object whose attribute names correspond to column names. |
| PDO::FETCH_BOUND (integer) | Specifies the fetch mode to return TRUE and assign the column values in the result set to the PHP variables bound via the PDOStatement::bindParam() or PDOStatement::bindColumn() methods. |
| PDO::FETCH_COLUMN (integer) | Specifies the fetch mode to return the needed column from the next row in the result set. |
| PDO::FETCH_CLASS (integer) | Specifies the fetch mode to return a new instance of the requested class, mapping columns to the corresponding property names in the class. |
|
Note: If the requested class does not have this property, the __set() magic method is called. |
|
| PDO::FETCH_INTO (integer) | Specifies the fetch mode to update an existing instance of the requested class, mapping columns to the corresponding property names in the class. |
| PDO::FETCH_FUNC (integer) | Allows fully custom handling of data at runtime. (Only valid in PDOStatement::fetchAll().) |
| PDO::FETCH_GROUP (integer) | Returns grouped by value. Usually used together with PDO::FETCH_COLUMN or PDO::FETCH_KEY_PAIR. |
| PDO::FETCH_UNIQUE (integer) | Take only unique values. |
| PDO::FETCH_KEY_PAIR (integer) | Fetch a two-column result set into an array where the first column is the key and the second column is the value. Available since PHP 5.2.3. |
| PDO::FETCH_CLASSTYPE (integer) | Determines the class name based on the value of the first column. |
| PDO::FETCH_SERIALIZE (integer) | Similar to PDO::FETCH_INTO, but represents the object as a serialized string. Available since PHP 5.1.0. Starting from PHP 5.3.0, if this flag is set, the class constructor is never called. |
| PDO::FETCH_PROPS_LATE (integer) | Calls the constructor before setting attributes. Available since PHP 5.2.0. |
| PDO::ATTR_AUTOCOMMIT (integer) | If this value is FALSE, PDO will attempt to disable auto-commit so the database connection begins a transaction. |
| PDO::ATTR_PREFETCH (integer) | Set the prefetch size to balance speed and memory usage for your application. Not all database/driver combinations support setting the prefetch size. A larger prefetch size improves performance but also uses more memory. |
| PDO::ATTR_TIMEOUT (integer) | Set the number of seconds to wait when connecting to the database. |
| PDO::ATTR_ERRMODE (integer) | For more information about this attribute, see the Errors and Error Handling section. |
| PDO::ATTR_SERVER_VERSION (integer) | This is a read-only attribute; returns the version information of the database service to which PDO is connected. |
| PDO::ATTR_CLIENT_VERSION (integer) | This is a read-only attribute; returns the version information of the client library used by the PDO driver. |
| PDO::ATTR_SERVER_INFO (integer) | This is a read-only attribute. Returns some meta-information about the database service to which PDO is connected. |
| PDO::ATTR_CONNECTION_STATUS (integer) | |
| PDO::ATTR_CASE (integer) | Force column names to the specified case using constants like PDO::CASE_*. |
| PDO::ATTR_CURSOR_NAME (integer) | Get or set the name of the cursor to use. Very useful when using scrollable cursors and positioned updates. |
| PDO::ATTR_CURSOR (integer) | Select the cursor type. PDO currently supports PDO::CURSOR_FWDONLY and PDO::CURSOR_SCROLL. Generally PDO::CURSOR_FWDONLY unless a scrollable cursor is really needed. |
| PDO::ATTR_DRIVER_NAME (string) | Returns the driver name.
Example of using PDO::ATTR_DRIVER_NAME: |
getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { echo "Running on mysql; doing something mysql specific here\n"; } ?> | | PDO::ATTR_ORACLE_NULLS (integer) | Converts an empty string to NULL in SQL when fetching data. | | PDO::ATTR_PERSISTENT (integer) | Requests a persistent connection rather than creating a new one. For more information about this attribute, see Connection and Connection Management. | | PDO::ATTR_STATEMENT_CLASS (integer) | | | PDO::ATTR_FETCH_CATALOG_NAMES (integer) | Adds the contained catalog name in front of each column name in the result set. The catalog name and column name are separated by a dot (.). This attribute is supported at the driver level, so some drivers may not support it. | | PDO::ATTR_FETCH_TABLE_NAMES (integer) | Adds the contained table name in front of each column name in the result set. The table name and column name are separated by a dot (.). This attribute is supported at the driver level, so some drivers may not support it. | | PDO::ATTR_STRINGIFY_FETCHES (integer) | | | PDO::ATTR_MAX_COLUMN_LEN (integer) | | | PDO::ATTR_DEFAULT_FETCH_MODE (integer) | Available since PHP 5.2.0. | | PDO::ATTR_EMULATE_PREPARES (integer) | Available since PHP 5.1.3. | | PDO::ERRMODE_SILENT (integer) | If an error occurs, no error or exception is displayed. Developers are expected to explicitly check for errors. This is the default mode. For more information about this attribute, see Errors and Error Handling. | | PDO::ERRMODE_WARNING (integer) | If an error occurs, a PHP E_WARNING message is displayed. For more information about this attribute, see Errors and Error Handling. | | PDO::ERRMODE_EXCEPTION (integer) | If an error occurs, a PDOException is thrown. For more information about this attribute, see Errors and Error Handling. | | PDO::CASE_NATURAL (integer) | Keeps the column names returned by the database driver. | | PDO::CASE_LOWER (integer) | Forces column names to lowercase. | | PDO::CASE_UPPER (integer) | Forces column names to uppercase. | | PDO::NULL_NATURAL (integer) | | | PDO::NULL_EMPTY_STRING (integer) | | | PDO::NULL_TO_STRING (integer) | | | PDO::FETCH_ORI_NEXT (integer) | Fetches the next row in the result set. Only valid for scrollable cursors. | | PDO::FETCH_ORI_PRIOR (integer) | Fetches the previous row in the result set. Only valid for scrollable cursors. | | PDO::FETCH_ORI_FIRST (integer) | Fetches the first row in the result set. Only valid for scrollable cursors. | | PDO::FETCH_ORI_LAST (integer) | Fetches the last row in the result set. Only valid for scrollable cursors. | | PDO::FETCH_ORI_ABS (integer) | Fetches the requested row from the result set by row number. Only valid for scrollable cursors. | | PDO::FETCH_ORI_REL (integer) | Fetches the requested row from the result set by relative position from the current cursor location. Only valid for scrollable cursors. | | PDO::CURSOR_FWDONLY (integer) | Creates a PDOStatement object with a forward-only cursor. This is the default cursor option because it is the fastest and the most commonly used data access pattern in PHP. | | PDO::CURSOR_SCROLL (integer) | Creates a PDOStatement object with a scrollable cursor. The rows fetched from the result set are controlled via the PDO::FETCH_ORI_* constants. | | PDO::ERR_NONE (string) | Corresponds to SQLSTATE '00000', meaning the SQL statement was issued successfully without error or warning. This constant is very convenient when using PDO::errorCode() or PDOStatement::errorCode() to determine whether an error occurred, and is frequently used when checking the error status code returned by the above methods. | | PDO::PARAM_EVT... [truncated]
PHP PDO Reference Manual