Php Pdo Constants
[PHP PDO Reference Manual](#)
The following constants are defined by this extension module, and are therefore only available after the extension module has been compiled into PHP, or dynamically loaded at runtime.
**Note:** PDO uses class constants since PHP 5.1. Earlier versions used the global constant form, such as PDO_PARAM_BOOL.
PDO::PARAM_BOOL (integer) Represents the boolean data type.
PDO::PARAM_NULL (integer) Represents the SQL NULL data type.
PDO::PARAM_INT (integer) Represents the SQL integer data type.
PDO::PARAM_STR (integer) Represents the SQL CHAR, VARCHAR, or other string data type.
PDO::PARAM_LOB (integer) Represents the SQL large object data type.
PDO::PARAM_STMT (integer) Represents a recordset type. Not currently supported by any driver.
PDO::PARAM_INPUT_OUTPUT (integer) Specifies that the parameter is an INOUT parameter for a stored procedure. Must be bitwise ORed with an explicit PDO::PARAM_* data type.
PDO::FETCH_LAZY (integer) Specifies the fetch mode. Returns each row in the result set as an object, where the variable names correspond to the column names. PDO::FETCH_LAZY creates the object variables used to access the data. Not effective in PDOStatement::fetchAll().
PDO::FETCH_ASSOC (integer) Specifies the fetch mode. Returns each row in the 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. Returns each row in the result set as an array indexed by column name. If the result set contains multiple columns with the same name, PDO::FETCH_NAMED returns an array of values for each column name.
PDO::FETCH_NUM (integer) Specifies the fetch mode. Returns each row in the result set as an array indexed by column number, starting from column 0.
PDO::FETCH_BOTH (integer) Specifies the fetch mode. Returns each row in the 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. Returns each row in the result set as an object with property names corresponding to column names.
PDO::FETCH_BOUND (integer) Specifies the fetch mode. Returns TRUE and assigns the column values from the result set to the PHP variables bound via the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.
PDO::FETCH_COLUMN (integer) Specifies the fetch mode. Returns the specified column from the next row in the result set.
PDO::FETCH_CLASS (integer) Specifies the fetch mode. Returns a new instance of the requested class, mapping columns to the corresponding property names in the class.
Note: If the requested property does not exist in the class, the __set() magic method is called.
PDO::FETCH_INTO (integer) Specifies the fetch mode. Updates an existing instance of the requested class, mapping columns to the corresponding property names in the class.
PDO::FETCH_FUNC (integer) Allows completely custom handling of the data during fetch. (Only effective in PDOStatement::fetchAll()).
PDO::FETCH_GROUP (integer) Returns values grouped. Typically used with PDO::FETCH_COLUMN or PDO::FETCH_KEY_PAIR.
PDO::FETCH_UNIQUE (integer) Fetches only unique values.
PDO::FETCH_KEY_PAIR (integer) Fetches 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) Sets properties before calling the constructor. Available since PHP 5.2.0.
PDO::ATTR_AUTOCOMMIT (integer) If this value is FALSE, PDO will attempt to disable autocommit so that the database connection begins a transaction.
PDO::ATTR_PREFETCH (integer) Sets 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) Sets the timeout in seconds for connecting to the database.
PDO::ATTR_ERRMODE (integer) For more information about this attribute, see the Error Handling section.
PDO::ATTR_SERVER_VERSION (integer) This is a read-only attribute; returns the version information of the database server that PDO is connected to.
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 server that PDO is connected to.
PDO::ATTR_CONNECTION_STATUS (integer)
PDO::ATTR_CASE (integer) Forces column names to a specific case using constants like PDO::CASE_*.
PDO::ATTR_CURSOR_NAME (integer) Gets or sets the name of the cursor to use. Useful when using scrollable cursors and positioned updates.
PDO::ATTR_CURSOR (integer) Selects the cursor type. PDO currently supports PDO::CURSOR_FWDONLY and PDO::CURSOR_SCROLL. Generally, PDO::CURSOR_FWDONLY is used unless a scrollable cursor is specifically needed.
PDO::ATTR_DRIVER_NAME (string) Returns the driver name.
Example using PDO::ATTR_DRIVER_NAME:
getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { echo "Running on mysql; doing something mysql specific heren";}?>
PDO::ATTR_ORACLE_NULLS (integer) Converts empty strings to SQL NULL when fetching data.
PDO::ATTR_PERSISTENT (integer) Requests a persistent connection, rather than creating a new connection. For more information about this attribute, see Connections and Connection Management.
PDO::ATTR_STATEMENT_CLASS (integer)
PDO::ATTR_FETCH_CATALOG_NAMES (integer) Prepends the catalog name to each column name in the result set. The catalog name and column name are separated by a decimal point (.). This attribute is supported at the driver level, so some drivers may not support it.
PDO::ATTR_FETCH_TABLE_NAMES (integer) Prepends the table name to each column name in the result set. The table name and column name are separated by a decimal point (.). 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 shown. The developer is expected to explicitly check for errors. This is the default mode. For more information about this attribute, see Error Handling.
PDO::ERRMODE_WARNING (integer) If an error occurs, a PHP E_WARNING message is displayed. For more information about this attribute, see Error Handling.
PDO::ERRMODE_EXCEPTION (integer) If an error occurs, a PDOException exception is thrown. For more information about this attribute, see Error Handling.
PDO::CASE_NATURAL (integer) Preserves the column names as 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 by row number from the result set. Only valid for scrollable cursors.
PDO::FETCH_ORI_REL (integer) Fetches the requested row relative to the current cursor position from the result set. 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 most common data access pattern in PHP.
PDO::CURSOR_SCROLL (integer) Creates a PDOStatement object with a scrollable cursor. Controls which row is fetched from the result set using the PDO::FETCH_ORI_* constants.
PDO::ERR_NONE (string) Corresponds to SQLSTATE '00000', indicating that the SQL statement was successfully issued with no errors or warnings. This constant is very useful when using PDO::errorCode() or PDOStatement::errorCode() to determine if an error occurred. It is frequently used when checking the error status code returned by these methods.
PDO::PARAM_EVT_ALLOC (integer) Allocation event.
PDO::PARAM_EVT_FREE (integer) Deallocation event.
PDO::PARAM_EVT_EXEC_PRE (integer) Triggered before executing a prepared statement.
PDO::PARAM_EVT_EXEC_POST (integer) Triggered after executing a prepared statement.
PDO::PARAM_EVT_FETCH_PRE (integer) Triggered before fetching a result from a result set.
PDO::PARAM_EVT_FETCH_POST (integer) Triggered after fetching a result from a result set.
PDO::PARAM_EVT_NORMALIZE (integer) Triggered when binding a parameter register to allow the driver to normalize the variable name.
* * PHP PDO Reference Manual](#)
YouTip