11111
PDO Functions
Внимание. Это расширение является ЭКСПЕРИМЕНТАЛЬНЫМ. Поведение этого расширения, включая имена его функций и относящуюся к нему документацию, может измениться в последующих версиях PHP без уведомления. Используйте это расширение на свой страх и риск.
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.
- Follow the same steps to install and enable the PDO drivers of your choice.
extension=php_pdo.dll |
extension=php_pdo.dll |
- These DLL's should exist in the systems extension_dir.
- Due to a bug in the pear installer you should install the PDO package manually using the following steps:
- Follow the same steps to install and enable the PDO drivers of your choice.
bash$ wget http://pecl.php.net/get/PDO |
export PATH="/usr/local/php5/bin:$PATH" |
bash$ tar xzf PDO-0.2.tgz |
-Поведение этих функций зависит от установок в php.ini.
Таблица 1. PDO Configuration Options
Name | Default | Changeable | Changelog |
---|---|---|---|
pdo.dsn.* | php.ini only | ||
pdo_odbc.connection_pooling | "strict" | PHP_INI_ALL |
Для подробного описания констант
PHP_INI_*, обратитесь к документации функции ini_set().
Краткое разъяснение конфигурационных
директив.
pdo.dsn.* string
- Defines DSN alias. See PDO::__construct for thorough explanation.
pdo_odbc.connection_pooling string
- Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" (equals to "").
- The following drivers currently implement the PDO interface:
Driver name | Supported databases |
---|---|
PDO_DBLIB | FreeTDS / Microsoft SQL Server / Sybase |
PDO_FIREBIRD | Firebird/Interbase 6 |
PDO_MYSQL | MySQL 3.x/4.0 |
PDO_OCI | Oracle Call Interface |
PDO_ODBC | ODBC v3 (IBM DB2, unixODBC and win32 ODBC) |
PDO_PGSQL | PostgreSQL |
PDO_SQLITE | SQLite 3.x |
sqlite | SQLite 2.x (PHP5.1 and up) |
- Represents a connection between PHP and a database server.
- Represents a prepared statement and, after the statement is executed, an associated result set.
-Перечисленные ниже константы определены данным расширением и могут быть
доступны только в том случае, если PHP был собран с
поддержкой этого расширения или же в том случае, если
данное расширение подгружается во время выполнения.
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)
PDO_PARAM_INPUT_OUTPUT (integer)
- Specifies that the parameter is an INOUT parameter for a stored procedure. You must bitwise-OR this value with an explicit PDO_PARAM_* data type.
PDO_FETCH_LAZY (integer)
- Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO_FETCH_LAZY creates the object variable names as they are accessed.
PDO_FETCH_ASSOC (integer)
- Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO_FETCH_ASSOC returns only a single value per column name.
PDO_FETCH_NAMED (integer)
- Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO_FETCH_NAMED returns an array of values per column name.
PDO_FETCH_NUM (integer)
- Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.
PDO_FETCH_BOTH (integer)
- Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.
PDO_FETCH_OBJ (integer)
- Specifies that the fetch method shall return each row as an object with property names that correspond to the column names returned in the result set.
PDO_FETCH_BOUND (integer)
- Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were bound with the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.
PDO_FETCH_COLUMN (integer)
- Specifies that the fetch method shall return only a single requested column from the next row in the result set.
PDO_FETCH_CLASS (integer)
- Specifies that the fetch method shall return a new instance of the requested class, mapping the columns to named properties in the class.
PDO_FETCH_INTO (integer)
- Specifies that the fetch method shall update an existing instance of the requested class, mapping the columns to named properties in the class.
PDO_FETCH_FUNC (integer)
PDO_FETCH_GROUP (integer)
PDO_FETCH_UNIQUE (integer)
PDO_FETCH_CLASSTYPE (integer)
PDO_ATTR_AUTOCOMMIT (integer)
- If this value is FALSE, PDO attempts to disable autocommit so that the connection begins a transaction.
PDO_ATTR_PREFETCH (integer)
- Setting the prefetch size allows you to balance speed against memory usage for your application. Not all database/driver combinations support setting of the prefetch size.
PDO_ATTR_TIMEOUT (integer)
- Sets the timeout value in seconds for communications with the database.
PDO_ATTR_ERRMODE (integer)
PDO_ATTR_SERVER_VERSION (integer)
PDO_ATTR_CLIENT_VERSION (integer)
PDO_ATTR_SERVER_INFO (integer)
PDO_ATTR_CONNECTION_STATUS (integer)
PDO_ATTR_CASE (integer)
- Force column names to a specific case specified by the PDO_CASE_* constants.
PDO_ATTR_CURSOR_NAME (integer)
PDO_ATTR_CURSOR (integer)
PDO_ATTR_DRIVER_NAME (string)
- Returns the name of the driver.
PDO_ATTR_ORACLE_NULLS (integer)
- Convert empty strings to SQL NULL values.
PDO_ATTR_PERSISTENT (integer)
Request a persistent connection, rather than creating a new connection.
PDO_ATTR_FETCH_CATALOG_NAMES (integer)
Prepend the containing catalog name to each column name returned in the result set. The catalog name and column name are separated by a decimal (.) character.
PDO_ATTR_FETCH_TABLE_NAMES (integer)
Prepend the containing table name to each column name returned in the result set. The table name and column name are separated by a decimal (.) character.
PDO_ERRMODE_SILENT (integer)
- Do not raise an error or exception if an error occurs. The developer is expected to explicitly check for errors. This is the default mode.
PDO_ERRMODE_WARNING (integer)
- Issue a PHP E_WARNING message if an error occurs.
PDO_ERRMODE_EXCEPTION (integer)
- Throw a PDOException if an error occurs.
PDO_CASE_NATURAL (integer)
- Leave column names as returned by the database driver.
PDO_CASE_LOWER (integer)
Force column names to lower case.
PDO_CASE_UPPER (integer)
- Force column names to upper case.
PDO_FETCH_ORI_NEXT (integer)
- Fetch the next row in the result set. Valid only for scrollable cursors.
PDO_FETCH_ORI_PRIOR (integer)
- Fetch the previous row in the result set. Valid only for scrollable cursors.
PDO_FETCH_ORI_FIRST (integer)
- Fetch the first row in the result set. Valid only for scrollable cursors.
PDO_FETCH_ORI_LAST (integer)
- Fetch the last row in the result set. Valid only for scrollable cursors.
PDO_FETCH_ORI_ABS (integer)
- Fetch the requested row by row number from the result set. Valid only for scrollable cursors.
PDO_FETCH_ORI_REL (integer)
- Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.
PDO_CURSOR_FWDONLY (integer)
- Create a PDOStatement object with a forward-only cursor. This may improve the performance of your application but restricts your PDOStatement object to fetching one row at a time from the result set in a forward direction.
PDO_CURSOR_SCROLL (integer)
- Create a PDOStatement object with a scrollable cursor. Pass the PDO_FETCH_ORI_* constants to control the rows fetched from the result set.
PDO_ERR_CANT_MAP (integer)
PDO_ERR_SYNTAX (integer)
PDO_ERR_CONSTRAINT (integer)
PDO_ERR_NOT_FOUND (integer)
PDO_ERR_ALREADY_EXISTS (integer)
PDO_ERR_NOT_IMPLEMENTED (integer)
PDO_ERR_MISMATCH (integer)
PDO_ERR_TRUNCATED (integer)
PDO_ERR_DISCONNECTED (integer)
PDO_ERR_NO_PERM (integer)
PDO_ERR_NONE (string)
Corresponds to SQLSTATE '00000', meaning that the SQL statement was successfully issued with no errors or warnings.
Содержание
PDO::beginTransaction -- Initiates a transaction
PDO::commit -- Commits a transaction
PDO::__construct -- Creates a PDO instance representing a connection to a database
PDO::errorCode -- Fetch the SQLSTATE associated with the last operation on the database handle
PDO::errorInfo -- Fetch extended error information associated with the last operation on the database handle
PDO::exec -- Execute an SQL statement and return the number of affected rows
PDO::getAttribute -- Retrieve a database connection attribute
PDO::lastInsertId -- Returns the ID of the last inserted row or sequence value
PDO::prepare -- Prepares a statement for execution and returns a statement object
PDO::query -- Executes an SQL statement, returning a result set as a PDOStatement object
PDO::quote -- Quotes a string for use in a query.
PDO::rollBack -- Rolls back a transaction
PDO::setAttribute -- Set an attribute
PDOStatement::bindColumn -- Bind a column to a PHP variable
PDOStatement::bindParam -- Binds a parameter to the specified variable name
PDOStatement::closeCursor -- Closes the cursor, enabling the statement to be executed again.
PDOStatement::columnCount -- Returns the number of columns in the result set
PDOStatement::errorCode -- Fetch the SQLSTATE associated with the last operation on the statement handle
PDOStatement::errorInfo -- Fetch extended error information associated with the last operation on the statement handle
PDOStatement::execute -- Executes a prepared statement
PDOStatement::fetch -- Fetches the next row from a result set
PDOStatement::fetchAll -- Returns an array containing all of the result set rows
PDOStatement::fetchColumn -- Returns a single column from the next row of a result set
PDOStatement::getAttribute -- Retrieve a statement attribute
PDOStatement::getColumnMeta -- Returns metadata for a column in a result set
PDOStatement::nextRowset -- Advances to the next rowset in a multi-rowset statement handle
PDOStatement::rowCount -- Returns the number of rows affected by the last SQL statement
PDOStatement::setAttribute -- Set a statement attribute
PDOStatement::setFetchMode -- Set the default fetch mode for this statement
pdo_drivers -- Return an array of available PDO drivers
pdf_translate
PDO::beginTransaction 22222