PDO Functions


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.

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.


PHP 5.1 and up on Unix systems
  1. If you're running a PHP 5.1 release, PDO and PDO_SQLITE is included in the distribution; it will be automatically enabled when you run configure. It is recommended that you build PDO as a shared extension, as this will allow you to take advantage of updates that are made available via PECL. The recommended configure line for building PHP with PDO support should enable zlib support (for the pecl installer) as well. You may also need to enable the PDO driver for your database of choice; consult the documentation for database-specific PDO drivers to find out more about that, but note that if you build PDO as a shared extension, you must build the PDO drivers as shared extensions. SQLite extension depends on PDO so if PDO is built as a shared extension, SQLite needs to be built the same way.

    ./configure --with-zlib --enable-pdo=shared --with-pdo-sqlite=shared --with-sqlite=shared

  2. After installing PDO as a shared module, you must edit your php.ini file so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step.


  3. Having PDO as a shared module will allow you to run pecl upgrade pdo as new versions of PDO are published, without forcing you to rebuild the whole of PHP. Note that if you do this, you also need to upgrade your database specific PDO drivers at the same time.

PHP 5.0.0 and up on Unix systems
  1. PDO is available as a PECL extension from » http://pecl.php.net/package/pdo. Installation can be performed via the pecl tool; this is enabled by default when you configure PHP. You should ensure that PHP was configured --with-zlib in order for pecl to be able to handle the compressed package files.

  2. Run the following command to download, build, and install the latest stable version of PDO:

    pecl install pdo

  3. The pecl command automatically installs the PDO module into your PHP extensions directory. To enable the PDO extension on Linux or Unix operating systems, you must add the following line to php.ini:


    For more information about building PECL packages, consult the PECL installation section of the manual.

Windows users running PHP 5.1.0 and up
  1. PDO and all the major drivers ship with PHP as shared extensions, and simply need to be activated by editing the php.ini file:


  2. Next, choose the other database-specific DLL files and either use dl() to load them at runtime, or enable them in php.ini below php_pdo.dll. For example:


    These DLLs should exist in the system's extension_dir. Note that PDO_INFORMIX is only available as a PECL extension.

실행시 설정

이 함수의 작동은 php.ini 설정에 영향을 받습니다.

PDO Configuration Options
Name Default Changeable Changelog
pdo.dsn.*   php.ini only  
PHP_INI_* 상수에 대한 자세한 상세와 정의는 php.ini directives를 참고하십시오.

위 설정 지시어에 대한 간단한 설명입니다.

pdo.dsn.* string

Defines DSN alias. See PDO->__construct() for thorough explanation.

PDO Drivers

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_INFORMIX IBM Informix Dynamic Server
PDO_MYSQL MySQL 3.x/4.x/5.x
PDO_OCI Oracle Call Interface
PDO_ODBC ODBC v3 (IBM DB2, unixODBC and win32 ODBC)
PDO_SQLITE SQLite 3 and SQLite 2

Connections and Connection management

Connections are established by creating instances of the PDO base class. It doesn't matter which driver you want to use; you always use the PDO class name. The constructor accepts parameters for specifying the database source (known as the DSN) and optionally for the username and password (if any).

Example#1 Connecting to MySQL

= new PDO('mysql:host=localhost;dbname=test'$user$pass);

If there are any connection errors, a PDOException object will be thrown. You may catch the exception if you want to handle the error condition, or you may opt to leave it for an application global exception handler that you set up via set_exception_handler().

Example#2 Handling connection errors

try {
$dbh = new PDO('mysql:host=localhost;dbname=test'$user$pass);
   foreach (
$dbh->query('SELECT * from FOO') as $row) {
$dbh null;
} catch (
PDOException $e) {
"Error!: " $e->getMessage() . "<br/>";

If your application does not catch the exception thrown from the PDO constructor, the default action taken by the zend engine is to terminate the script and display a back trace. This back trace will likely reveal the full database connection details, including the username and password. It is your responsibility to catch this exception, either explicitly (via a catch statement) or implicitly via set_exception_handler().

Upon successful connection to the database, an instance of the PDO class is returned to your script. The connection remains active for the lifetime of that PDO object. To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted--you do this by assigning NULL to the variable that holds the object. If you don't do this explicitly, PHP will automatically close the connection when your script ends.

Example#3 Closing a connection

= new PDO('mysql:host=localhost;dbname=test'$user$pass);
// use the connection here

// and now we're done; close it
$dbh null;

Many web applications will benefit from making persistent connections to database servers. Persistent connections are not closed at the end of the script, but are cached and re-used when another script requests a connection using the same credentials. The persistent connection cache allows you to avoid the overhead of establishing a new connection every time a script needs to talk to a database, resulting in a faster web application.

Example#4 Persistent connections

= new PDO('mysql:host=localhost;dbname=test'$user$pass, array(

Note: If you wish to use persistent connections, you must set PDO::ATTR_PERSISTENT in the array of driver options passed to the PDO constructor. If setting this attribute with PDO->setAttribute() after instantiation of the object, the driver will not use persistent connections.

Note: If you're using the PDO ODBC driver and your ODBC libraries support ODBC Connection Pooling (unixODBC and Windows are two that do; there may be more), then it's recommended that you don't use persistent PDO connections, and instead leave the connection caching to the ODBC Connection Pooling layer. The ODBC Connection Pool is shared with other modules in the process; if PDO is told to cache the connection, then that connection would never be returned to the ODBC connection pool, resulting in additional connections being created to service those other modules.

Transactions and auto-commit

Now that you're connected via PDO, you must understand how PDO manages transactions before you start issuing queries. If you've never encountered transactions before, they offer 4 major features: Atomicity, Consistency, Isolation and Durability (ACID). In layman's terms, any work carried out in a transaction, even if it is carried out in stages, is guaranteed to be applied to the database safely, and without interference from other connections, when it is committed. Transactional work can also be automatically undone at your request (provided you haven't already committed it), which makes error handling in your scripts easier.

Transactions are typically implemented by "saving-up" your batch of changes to be applied all at once; this has the nice side effect of drastically improving the efficiency of those updates. In other words, transactions can make your scripts faster and potentially more robust (you still need to use them correctly to reap that benefit).

Unfortunately, not every database supports transactions, so PDO needs to run in what is known as "auto-commit" mode when you first open the connection. Auto-commit mode means that every query that you run has its own implicit transaction, if the database supports it, or no transaction if the database doesn't support transactions. If you need a transaction, you must use the PDO->beginTransaction() method to initiate one. If the underlying driver does not support transactions, a PDOException will be thrown (regardless of your error handling settings: this is always a serious error condition). Once you are in a transaction, you may use PDO->commit() or PDO->rollBack() to finish it, depending on the success of the code you run during the transaction.

When the script ends or when a connection is about to be closed, if you have an outstanding transaction, PDO will automatically roll it back. This is a safety measure to help avoid inconsistency in the cases where the script terminates unexpectedly--if you didn't explicitly commit the transaction, then it is assumed that something went awry, so the rollback is performed for the safety of your data.


The automatic rollback only happens if you initiate the transaction via PDO->beginTransaction(). If you manually issue a query that begins a transaction PDO has no way of knowing about it and thus cannot roll it back if something bad happens.

Example#5 Executing a batch in a transaction

In the following sample, let's assume that we are creating a set of entries for a new employee, who has been assigned an ID number of 23. In addition to entering the basic data for that person, we also need to record their salary. It's pretty simple to make two separate updates, but by enclosing them within the PDO->beginTransaction() and PDO->commit() calls, we are guaranteeing that no one else will be able to see those changes until they are complete. If something goes wrong, the catch block rolls back all changes made since the transaction was started, and then prints out an error message.

try {
$dbh = new PDO('odbc:SAMPLE''db2inst1''ibmdb2'

$dbh->exec("insert into staff (id, first, last) values (23, 'Joe', 'Bloggs')");
$dbh->exec("insert into salarychange (id, amount, changedate) 
      values (23, 50000, NOW())"
} catch (
Exception $e) {
"Failed: " $e->getMessage();

You're not limited to making updates in a transaction; you can also issue complex queries to extract data, and possibly use that information to build up more updates and queries; while the transaction is active, you are guaranteed that no one else can make changes while you are in the middle of your work. In truth, this isn't 100% correct, but it is a good-enough introduction, if you've never heard of transactions before.

Prepared statements and stored procedures

Many of the more mature databases support the concept of prepared statements. What are they? You can think of them as a kind of compiled template for the SQL that you want to run, that can be customized using variable parameters. Prepared statements offer two major benefits:

  • The query only needs to be parsed (or prepared) once, but can be executed multiple times with the same or different parameters. When the query is prepared, the database will analyze, compile and optimize it's plan for executing the query. For complex queries this process can take up enough time that it will noticeably slow down your application if you need to repeat the same query many times with different parameters. By using a prepared statement you avoid repeating the analyze/compile/optimize cycle. In short, prepared statements use fewer resources and thus run faster.
  • The parameters to prepared statements don't need to be quoted; the driver handles it for you. If your application exclusively uses prepared statements, you can be sure that no SQL injection will occur. (However, if you're still building up other parts of the query based on untrusted input, you're still at risk).

Prepared statements are so useful that they are the only feature that PDO will emulate for drivers that don't support them. This ensures that you will be able to use the same data access paradigm regardless of the capabilities of the database.

Example#6 Repeated inserts using prepared statements

This example performs an INSERT query by substituting a name and a value for the named placeholders.

$dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");

// insert one row
$name 'one';
$value 1;

// insert another row with different values
$name 'two';
$value 2;

Example#7 Repeated inserts using prepared statements

This example performs an INSERT query by substituting a name and a value for the positional ? placeholders.

$dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");

// insert one row
$name 'one';
$value 1;

// insert another row with different values
$name 'two';
$value 2;

Example#8 Fetching data using prepared statements

This example fetches data based on a key value supplied by a form. The user input is automatically quoted, so there is no risk of a SQL injection attack.

$dbh->prepare("SELECT * FROM REGISTRY where name = ?");
if (
$stmt->execute(array($_GET['name']))) {
  while (
$row $stmt->fetch()) {

If the database driver supports it, you may also bind parameters for output as well as input. Output parameters are typically used to retrieve values from stored procedures. Output parameters are slightly more complex to use than input parameters, in that you must know how large a given parameter might be when you bind it. If the value turns out to be larger than the size you suggested, an error is raised.

Example#9 Calling a stored procedure with an output parameter

$dbh->prepare("CALL sp_returns_string(?)");

// call the stored procedure

"procedure returned $return_value\n";

You may also specify parameters that hold values both input and output; the syntax is similar to output parameters. In this next example, the string 'hello' is passed into the stored procedure, and when it returns, hello is replaced with the return value of the procedure.

Example#10 Calling a stored procedure with an input/output parameter

$dbh->prepare("CALL sp_takes_string_returns_string(?)");
$value 'hello';

// call the stored procedure

"procedure returned $value\n";

Example#11 Invalid use of placeholder

$dbh->prepare("SELECT * FROM REGISTRY where name LIKE '%?%'");

// placeholder must be used in the place of the whole value
$stmt $dbh->prepare("SELECT * FROM REGISTRY where name LIKE ?");

Errors and error handling

PDO offers you a choice of 3 different error handling strategies, to fit your style of application development.


    This is the default mode. PDO will simply set the error code for you to inspect using the PDO->errorCode() and PDO->errorInfo() methods on both the statement and database objects; if the error resulted from a call on a statement object, you would invoke the PDOStatement->errorCode() or PDOStatement->errorInfo() method on that object. If the error resulted from a call on the database object, you would invoke those methods on the database object instead.


    In addition to setting the error code, PDO will emit a traditional E_WARNING message. This setting is useful during debugging/testing, if you just want to see what problems occurred without interrupting the flow of the application.


    In addition to setting the error code, PDO will throw a PDOException and set its properties to reflect the error code and error information. This setting is also useful during debugging, as it will effectively "blow up" the script at the point of the error, very quickly pointing a finger at potential problem areas in your code (remember: transactions are automatically rolled back if the exception causes the script to terminate).

    Exception mode is also useful because you can structure your error handling more clearly than with traditional PHP-style warnings, and with less code/nesting than by running in silent mode and explicitly checking the return value of each database call.

    See Exceptions for more information about Exceptions in PHP.

PDO standardizes on using SQL-92 SQLSTATE error code strings; individual PDO drivers are responsible for mapping their native codes to the appropriate SQLSTATE codes. The PDO->errorCode() method returns a single SQLSTATE code. If you need more specific information about an error, PDO also offers an PDO->errorInfo() method which returns an array containing the SQLSTATE code, the driver specific error code and driver specific error string.

Large Objects (LOBs)

At some point in your application, you might find that you need to store "large" data in your database. Large typically means "around 4kb or more", although some databases can happily handle up to 32kb before data becomes "large". Large objects can be either textual or binary in nature. PDO allows you to work with this large data type by using the PDO::PARAM_LOB type code in your PDOStatement->bindParam() or PDOStatement->bindColumn() calls. PDO::PARAM_LOB tells PDO to map the data as a stream, so that you can manipulate it using the PHP Streams API.

Example#12 Displaying an image from a database

This example binds the LOB into the variable named $lob and then sends it to the browser using fpassthru(). Since the LOB is represented as a stream, functions such as fgets(), fread() and stream_get_contents() can be used on it.

= new PDO('odbc:SAMPLE''db2inst1''ibmdb2');
$stmt $db->prepare("select contenttype, imagedata from images where id=?");

header("Content-Type: $type");

Example#13 Inserting an image into a database

This example opens up a file and passes the file handle to PDO to insert it as a LOB. PDO will do its best to get the contents of the file up to the database in the most efficient manner possible.

= new PDO('odbc:SAMPLE''db2inst1''ibmdb2');
$stmt $db->prepare("insert into images (id, contenttype, imagedata) values (?, ?, ?)");
$id get_new_id(); // some function to allocate a new ID

// assume that we are running as part of a file upload form
// You can find more information in the PHP documentation

$fp fopen($_FILES['file']['tmp_name'], 'rb');



Example#14 Inserting an image into a database: Oracle

Oracle requires a slightly different syntax for inserting a lob from a file. It's also essential that you perform the insert under a transaction, otherwise your newly inserted LOB will be committed with a zero-length as part of the implicit commit that happens when the query is executed:

= new PDO('oci:''scott''tiger');
$stmt $db->prepare("insert into images (id, contenttype, imagedata) " .
"VALUES (?, ?, EMPTY_BLOB()) RETURNING imagedata INTO ?");
$id get_new_id(); // some function to allocate a new ID

// assume that we are running as part of a file upload form
// You can find more information in the PHP documentation

$fp fopen($_FILES['file']['tmp_name'], 'rb');



예약 클래스


Represents a connection between PHP and a database server.


  • PDO - constructs a new PDO object


  • beginTransaction - begins a transaction

  • commit - commits a transaction

  • errorCode - retrieves an error code, if any, from the database

  • errorInfo - retrieves an array of error information, if any, from the database

  • exec - issues an SQL statement and returns the number of affected rows

  • getAttribute - retrieves a database connection attribute

  • lastInsertId - retrieves the value of the last row that was inserted into a table

  • prepare - prepares an SQL statement for execution

  • query - issues an SQL statement and returns a result set

  • quote - returns a quoted version of a string for use in SQL statements

  • rollBack - roll back a transaction

  • setAttribute - sets a database connection attribute


Represents a prepared statement and, after the statement is executed, an associated result set.


  • bindColumn - binds a PHP variable to an output column in a result set

  • bindParam - binds a PHP variable to a parameter in the prepared statement

  • bindValue - binds a value to a parameter in the prepared statement

  • closeCursor - closes the cursor, allowing the statement to be executed again

  • columnCount - returns the number of columns in the result set

  • errorCode - retrieves an error code, if any, from the statement

  • errorInfo - retrieves an array of error information, if any, from the statement

  • execute - executes a prepared statement

  • fetch - fetches a row from a result set

  • fetchAll - fetches an array containing all of the rows from a result set

  • fetchColumn - returns the data from a single column in a result set

  • getAttribute - retrieves a PDOStatement attribute

  • getColumnMeta - retrieves metadata for a column in the result set

  • nextRowset - retrieves the next rowset (result set)

  • rowCount - returns the number of rows that were affected by the execution of an SQL statement

  • setAttribute - sets a PDOStatement attribute

  • setFetchMode - sets the fetch mode for a PDOStatement


Represents an error raised by PDO. You should not throw a PDOException from your own code. See Exceptions for more information about Exceptions in PHP.

Example#15 The PDOException class

class PDOException extends Exception
$errorInfo null;    // corresponds to PDO::errorInfo()
                                 // or PDOStatement::errorInfo()
protected $message;          // textual error message
                                 // use Exception::getMessage() to access it
protected $code;             // SQLSTATE error code
                                 // use Exception::getCode() to access it

예약 상수

이 확장은 다음의 상수들을 정의합니다. 이 확장을 PHP에 내장했거나, 실행시에 동적으로 읽어들일 경우에만 사용할 수 있습니다.


PDO는 PHP 5.1부터 클래스 상수를 사용합니다. 이전 릴리즈는 PDO_PARAM_BOOL 형식의 전역 상수를 사용합니다.

PDO::PARAM_BOOL (integer)
불 자료형을 의미합니다.
PDO::PARAM_NULL (integer)
SQL NULL 자료형을 의미합니다.
PDO::PARAM_INT (integer)
SQL INTEGER 자료형을 의미합니다.
PDO::PARAM_STR (integer)
SQL CHAR, VARCHAR, 기타 문자열 자료형을 의미합니다.
PDO::PARAM_LOB (integer)
SQL large object 자료형을 의미합니다.
PDO::PARAM_STMT (integer)
recordset 형을 의미합니다. 현재 지원하는 드라이버는 없습니다.
저장된 프로시져에서 매개 변수를 INOUT 매개 변수로 지정합니다. 이 값은 명시적인 PDO::PARAM_* 자료형과 비트 OR 연산을 해야 합니다.
PDO::FETCH_LAZY (integer)
결과셋에서 각 행이 컬럼 이름을 변수명으로 가지는 객체를 반환하는 페치 방식을 지정합니다. PDO::FETCH_LAZY는 접근한 것과 동일한 객체 변수명을 작성합니다.
PDO::FETCH_ASSOC (integer)
결과셋에서 각 행이 컬럼 이름을 키로 가지는 배열을 반환하는 페치 방식을 지정합니다. 결과셋에 동일한 이름을 가지는 컬럼이 여러 개 있을 경우, PDO::FETCH_ASSOC는 각 컬럼 이름에서 하나의 값만 반환합니다.
PDO::FETCH_NAMED (integer)
결과셋에서 각 행이 컬럼 이름을 키로 가지는 배열을 반환하는 페치 방식을 지정합니다. 결과셋에 동일한 이름을 가지는 컬럼이 여러 개 있을 경우, PDO::FETCH_NAMED는 각 컬럼 이름에 해당하는 값들을 배열로 반환합니다.
PDO::FETCH_NUM (integer)
결과셋에서 각 행이 컬럼 번호를 키로 가지는 배열을 반환하는 페치 방식을 지정합니다. 컬럼 번호는 0부터 시작합니다.
PDO::FETCH_BOTH (integer)
결과셋에서 각 행이 컬럼 번호, 컬럼 이름 모두를 키로 가지는 배열을 반환하는 페치 방식을 지정합니다. 컬럼 번호는 0부터 시작합니다.
PDO::FETCH_OBJ (integer)
결과셋에서 각 행이 컬럼 이름과 동일한 프로퍼티를 가지는 객체를 반환하는 페치 방식을 지정합니다.
PDO::FETCH_BOUND (integer)
결과셋에서 컬럼 값을 PDOStatement::bindParam()이나 PDOStatement::bindColumn() 메쏘드를 실행한 것 처럼 바인드하고, TRUE를 반환하는 페치 방식을 지정합니다.
요청한 하나의 컬럼을 결과셋의 다음 행에서 반환하는 페치 방식을 지정합니다.
PDO::FETCH_CLASS (integer)
요청한 클래스에 컬럼 이름과 동일한 프로퍼티를 매핑한 새 인스턴스를 반환하는 페치 방식을 지정합니다.
PDO::FETCH_INTO (integer)
요청한 클래스의 존재하는 인스턴스에 컬럼에 해당하는 프로퍼티를 매핑하여 반환하는 페치 방식을 지정합니다.
PDO::FETCH_FUNC (integer)

PDO::FETCH_GROUP (integer)


첫번째 컬럼을 키로 가지고, 나머지 컬럼을 값으로 가지는 배열 형식으로 페치합니다.

PHP 5.1.0부터 사용할 수 있습니다.
PHP 5.2.0부터 사용할 수 있습니다.
이 값을 FALSE로 하면, PDO는 자동 커밋을 비활성화해서 연결이 트랙잭션을 시작하도록 합니다.
프리페치 크기를 정하여 어플리케이션의 메모리 사용량과 속도 사이에 밸런스를 맞출 수 있도록 합니다. 모든 데이터베이스/드라이버 조합이 프리페치 크기 설정을 지원하지는 않습니다. 큰 프리페치 크기는 퍼포먼스를 향상시키지만 메모리를 많이 사용합니다.
데이터베이스와 통신에서 시간 초과 값을 초 단위로 설정합니다.
이 속성에 대한 정보는 오류와 오류 다루기를 참고하십시오.
읽기 전용 속성입니다; PDO가 접속하고 있는 데이터베이스 서버 버전을 반환합니다.
읽기 전용 속성입니다; PDO 드라이버가 사용하고 있는 클라이언트 라이브러리 버전을 반환합니다.
읽기 전용 속성입니다; PDO가 접속하고 있는 데이터베이스 서버에 대한 정보를 반환합니다.

PDO::ATTR_CASE (integer)
컬럼 이름의 대소문자를 지정한 PDO::CASE_* 상수에 따라 강제합니다.
커서로 사용할 이름을 지정하거나 가져옵니다. 스크롤 가능한 커서로 위치 지정 갱신을 할 때 유용합니다.
PDO::ATTR_CURSOR (integer)
커서 형식을 지정합니다. PDO는 현재 PDO::CURSOR_FWDONLYPDO::CURSOR_SCROLL을 지원합니다. 스크롤 가능한 커서가 필요하지 않은 이상 PDO::CURSOR_FWDONLY를 사용하십시오.
드라이버 이름을 반환합니다.

Example#16 using PDO::ATTR_DRIVER_NAME

if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
"mysql 실 행중입니다; mysql 한정 명령은 여기서 실행합니다.\n";
자료 페치시에 빈 문자열을 SQL NULL 값으로 변경합니다.
새로운 접속을 만드는 대신, 영구 접속을 요청합니다. 이 속성에 대한 정보는 접속과 접속 관리를 참고하십시오.

결과셋에서 반환하는 각 컬럼 이름 앞에 카탈로그 이름을 붙입니다. 카탈로그 이름과 컬럼 이름 사이는 점으로 구분됩니다. 이 속성은 드라이버에서 지원합니다; 사용하는 드라이버가 지원하지 않을 수도 있습니다.
결과셋에서 반환하는 각 컬럼 이름 앞에 테이블 이름을 붙입니다. 테이블 이름과 컬럼 이름 사이는 점(.)으로 구분됩니다. 이 속성은 드라이버에서 지원합니다; 사용하는 드라이버가 지원하지 않을 수도 있습니다.


PHP 5.2.0부터 사용할 수 있습니다.
PHP 5.1.3부터 사용할 수 있습니다.
오류가 발생했을 때 아무런 오류나 예외를 발생시키지 않습니다. 개발자는 명시적으로 오류를 확인해야 합니다. 이것이 기본값입니다. 이 속성에 대한 자세한 정보는 오류와 오류 다루기를 참고하십시오.
오류가 발생했을 때 PHP E_WARNING 메세지를 발생시킵니다. 이 속성에 대한 자세한 정보는 오류와 오류 다루기를 참고하십시오.
오류가 발생했을 때 PDOException을 발생시킵니다. 이 속성에 대한 자세한 정보는 오류와 오류 다루기를 참고하십시오.
데이터베이스 드라이버가 반환한 컬럼 이름을 그대로 사용합니다.
PDO::CASE_LOWER (integer)
컬럼 이름을 소문자로 바꿉니다.
PDO::CASE_UPPER (integer)
컬럼 이름을 대문자로 바꿉니다.



결과셋에서 다음 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
결과셋에서 이전 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
결과셋에서 처음 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
결과셋에서 마지막 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
PDO::FETCH_ORI_ABS (integer)
결과셋에서 행 번호로 요청한 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
PDO::FETCH_ORI_REL (integer)
결과셋에서 현재 커서 위치에 대한 상대적 위치로 요청한 요청한 행을 가져옵니다. 스크롤 가능한 커서에서만 사용할 수 있습니다.
PDOStatement 객체를 진행 전용 커서로 생성합니다. 기본값으로써, PHP에서 가장 빠르고 일반적인 데이터 접근 방식입니다.
PDOStatement 객체를 스크롤 가능한 커서로 생성합니다. 결과셋에서 가져올 행을 PDO::FETCH_ORI_* 상수를 사용하여 제어할 수 있습니다.
PDO::ERR_NONE (string)
SQLSTATE '00000'에 해당합니다. SQL 구문이 아무런 오류나 경고 없이 성공적으로 처리되었음을 의미합니다. PDO::errorCode()PDOStatement::errorCode()로 오류 발생 여부를 확인할 때 유용합니다. 물론, 오류 발생 여부는 메쏘드 반환값으로 확인하는 것이 일반적입니다.
이벤트를 할당합니다.
이벤트를 제거합니다.
준비된 구문을 실행하기 전에 이벤트를 발생시킵니다.
준비된 구문을 실행한 후에 이벤트를 발생시킵니다.
결과셋에서 페치하기 전에 이벤트를 발생시킵니다.
결과셋에서 페치한 후에 이벤트를 발생시킵니다.
드라이버가 매개변수 이름을 표준화할 수 있도록, 매개변수를 바인드 하는 동안에 이벤트를 발생시킵니다.

Table of Contents

'MySQL' 카테고리의 다른 글

대용량 DB를 위한 한걸음 : MySQL Partitioning  (0) 2012.06.02
php mysql pdo 예제  (0) 2010.07.16
utf-8 설정했어도 한글 깨질때.....  (0) 2010.07.03
A테이블에는 있고 B테이블에 없는 데이터 찾기  (0) 2010.05.24
여러 컬럼의 subquery  (0) 2010.05.24
subquery  (0) 2010.05.24

+ Recent posts