Home > Backend Development > PHP Tutorial > Note 002 PHP Data Object (PDO) predefined constants

Note 002 PHP Data Object (PDO) predefined constants

黄舟
Release: 2023-03-04 08:50:01
Original
1123 people have browsed it

Name                                                                                                                                                    .

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 CHAR, VARCHAR or other string types in SQL.

PDO::PARAM_LOB (integer) represents the large object data type in SQL.

PDO::PARAM_STMT (integer) Represents a recordset type. It is not currently supported by any driver.

PDO::PARAM_INPUT_OUTPUT (integer) Specifies the parameter as an INOUT parameter of a stored procedure. This value must be bitwise ORed with an explicit PDO::PARAM_* data type.

PDO::FETCH_LAZY (integer) Specifies the acquisition method and returns each row in the result set as an object. The variable name of this object corresponds to the column name. PDO::FETCH_LAZY creates the object variable name for access. Not valid in PDOStatement::fetchAll().

PDO::FETCH_ASSOC (integer) Specifies the acquisition method and returns each row in the corresponding result set as an array indexed by the 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 acquisition method and returns each row in the corresponding result set as an array indexed by the 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 acquisition method and returns each row in the corresponding result set as an array indexed by the column number, starting from column 0.

PDO::FETCH_BOTH (integer) Specifies the acquisition method, and returns each row in the corresponding result set as an array indexed by column number and column name, starting from column 0.

PDO::FETCH_OBJ (integer) Specifies the acquisition method and returns each row in the result set as an object whose attribute name corresponds to the column name.

PDO::FETCH_BOUND (integer) Specifies the acquisition method, returns TRUE and assigns the column value in the result set to the PHP variable bound through the PDOStatement::bindParam() or PDOStatement::bindColumn() method.

PDO::FETCH_COLUMN (integer) Specifies the acquisition method and returns the required column from the next row in the result set.

PDO::FETCH_CLASS (integer) Specifies the acquisition method, returns a new instance of the requested class, and maps the column to the corresponding attribute name in the class. Note: If the attribute does not exist in the requested class, call the __set() magic method

PDO::FETCH_INTO (integer) to specify the acquisition method, update an existing instance of the requested class, and map the column to The corresponding attribute name in the class.

PDO::FETCH_FUNC (integer) Allows completely customized processing of data at runtime. (Only valid in PDOStatement::fetchAll()).

PDO::FETCH_GROUP (integer) Returns grouped by value. Typically used with PDO::FETCH_COLUMN or PDO::FETCH_KEY_PAIR.

PDO::FETCH_UNIQUE (integer) Only takes unique values.

PDO::FETCH_KEY_PAIR (integer) Get a result set with two columns into an array, where the first column is the key name and the second column is the value. Available since PHP 5.2.3.

PDO::FETCH_CLASSTYPE (integer) Determine 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 with PHP 5.3.0, if this flag is set, the class's constructor is never called.

PDO::FETCH_PROPS_LATE (integer) Call the constructor before setting properties. 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 can start 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. Larger prefetch sizes result in improved performance but also consume more memory.

PDO::ATTR_TIMEOUT (integer) Set the timeout seconds for connecting to the database.

PDO::ATTR_ERRMODE (integer) See the Errors and Error Handling section for more information about this attribute.

PDO::ATTR_SERVER_VERSION (integer) This is a read-only attribute; returns the version information of the database service connected to PDO.

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) Use constants like PDO::CASE_* to force column names to the specified case.

PDO::ATTR_CURSOR_NAME (integer) Gets or sets the name of the cursor. 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. Typically PDO::CURSOR_FWDONLY unless a scrollable cursor is really needed.

PDO::ATTR_DRIVER_NAME (string) Returns the driver name.

PDO::ATTR_ORACLE_NULLS (integer) Converts empty strings to NULL in SQL when retrieving data.

PDO::ATTR_PERSISTENT (integer) Requests a persistent connection instead of creating a new one. See Connections and Connection Management for more information about this property.

PDO::ATTR_STATEMENT_CLASS (integer)

PDO::ATTR_FETCH_CATALOG_NAMES (integer) Appends the contained catalog name to the front of each column name in the result set. Directory names and column names are separated by a decimal point (.). This property is supported at the driver level, so some drivers may not support this property.

PDO::ATTR_FETCH_TABLE_NAMES (integer) Appends the included table name to the front of each column name in the result set. Table names and column names are separated by a decimal point (.). This property is supported at the driver level, so some drivers may not support this property.

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 will be displayed. Hopefully developers will check for errors explicitly. This is the default mode. See Errors and Error Handling for more information about this property.

PDO::ERRMODE_WARNING (integer) If an error occurs, display a PHP E_WARNING message. See Errors and Error Handling for more information about this property.

PDO::ERRMODE_EXCEPTION (integer) If an error occurs, a PDOException is thrown. See Errors and Error Handling for more information about this property.

PDO::CASE_NATURAL (integer) Retains the column name returned by the database driver.

PDO::CASE_LOWER (integer) Forces column names to be lowercase.

PDO::CASE_UPPER (integer) Force column names to be uppercase.

PDO::NULL_NATURAL (integer)

PDO::NULL_EMPTY_STRING (integer)

PDO::NULL_TO_STRING (integer)

PDO::FETCH_ORI_NEXT ( integer) Gets the next row in the result set. Valid only for scrollable cursors.

PDO::FETCH_ORI_PRIOR (integer) Get the previous row in the result set. Valid only for scrollable cursors.

PDO::FETCH_ORI_FIRST (integer) Get the first row in the result set. Valid only for scrollable cursors.

PDO::FETCH_ORI_LAST (integer) Get the last row in the result set. Valid only for scrollable cursors.

PDO::FETCH_ORI_ABS (integer) Get the required rows from the result set based on the row number. Valid only for scrollable cursors.

PDO::FETCH_ORI_REL (integer) Get the required rows from the result set based on the relative position of the current cursor position. Valid only for scrollable cursors.

PDO::CURSOR_FWDONLY (integer) Create a PDOStatement object that only enters the cursor. This is the default cursor option because this cursor is the fastest and the most common data access mode in PHP.

PDO::CURSOR_SCROLL (integer) Create a PDOStatement object that can scroll the cursor. Control the rows fetched in the result set through the PDO::FETCH_ORI_* constants.

PDO::ERR_NONE (string) Corresponds to SQLSTATE '00000', indicating that the SQL statement was successfully issued without errors or warnings. This constant is convenient when using PDO::errorCode() or PDOStatement::errorCode() to determine whether an error occurred. Often used when checking error status codes returned by the above methods.

PDO::PARAM_EVT_ALLOC (integer) Assignment event

PDO::PARAM_EVT_FREE (integer) Deallocation event

PDO::PARAM_EVT_EXEC_PRE (integer) Event triggered before executing a prepared statement.

PDO::PARAM_EVT_EXEC_POST (integer) Triggers an event after executing a prepared statement.

PDO::PARAM_EVT_FETCH_PRE (integer) Triggers the event before fetching a result from a result set.

PDO::PARAM_EVT_FETCH_POST (integer) Triggers the event after taking a result from a result set.

PDO::PARAM_EVT_NORMALIZE (integer) Event fired when a bind parameter is registered to allow the driver to normalize variable names.

The above is the content of Note 002 PHP Data Object (PDO) predefined constants. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template