PDO Database Abstraction Layer

Source: Internet
Author: User
Tags error handling

New PDO ($dsn, $username, $passwd [, $options])

$options can set database connection properties, such as:

$options =array (pdo::attr_autocommit=>0,pdo::attr_autocommit=>pdo::errmode_exception);

EXEC () cannot perform a select operation; exec () returns FALSE if the SQL statement is wrong

ErrorInfo () return value is an array that contains:0->sqlstate,1-> error code,2-> error message

Query () returns FALSE if SQL statement is incorrect

Prepare () Prepares a statement, execute () executes this statement

QUOTE () returns a quoted string and filters the special characters in the string with a backslash escape

Some common parameters for SetAttribute () and GetAttribute (): (A successful call returns the requested PDO property value.) return null if unsuccessful)

The following constants are applied to the database connection:

  • Pdo::attr_autocommit whether to submit automatically
  • pdo::attr_case field names are case-sensitive
  • Pdo::attr_client_version Client Version
  • Pdo::attr_connection_status Connection Status
  • Pdo::attr_driver_name
  • Pdo::attr_errmode Default error handling mode
  • Pdo::attr_oracle_nulls returns an empty string, converted to NULL for SQL
  • Pdo::attr_persistent database is persistent connection
  • Pdo::attr_prefetch
  • Pdo::attr_server_info Server information
  • Pdo::attr_server_version Server version
  • Pdo::attr_timeout Time-out setting

Several modes of Setfetchmode (): Setfetchmode (PDO::FETCH_ASSOC) Setfetchmode (Pdo::fetch_both) Setfetchmode (PDO::FETCH_OBJ)

You can also set several modes of fetch ()/Fetch_all () Directly: Fetch (PDO::FETCH_ASSOC) FETCH (Pdo::fetch_both) fetch (pdo::fetch_obj)

RowCount () can also return the number of rows of the result set obtained by the SELECT statement

PDO Database Abstraction Layer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.