Recommended 10 articles for PHP PDO

Source: Internet
Author: User
Tags stack trace
PDO::p repare-prepare the SQL statement to execute and return a Pdostatement object (PHP 5 >= 5.1.0, PECL PDO >= 0.1.0) Description Syntax public pdostatement PDO::p Repa Re (string $statement [, array $driver _options = Array ()]) prepares the SQL statement to execute for the Pdostatement::execute () method, and the SQL statement can contain 0 or more names (: Nam e) or a question mark (?) parameter marker, which is replaced when SQL executes. You cannot include both a named (: name) or a question mark (?) parameter marker in an SQL statement, only one of these styles can be selected. Parameters in a preprocessed SQL statement are used Pdost

1. mysql PDO::p repare usage

Introduction: PDO::P repare-prepare the SQL statement to execute and return a Pdostatement object (PHP 5 >= 5.1.0, PECL PDO >= 0.1.0) Description Syntax public pdostatement PDO: :p repare (String $statement [, array $driver _options = Array ()])

2. Call the construction method to create a PDO object in several ways

Summary: You can create a PDO object in a variety of ways, such as connecting MySQL and Oracle servers, and describing the various invocation methods of the construction method, respectively.

3. Detailed description of stored procedures in PDO

Summary: The stored procedures in PDO allow data to be manipulated closer to the data, thereby reducing the use of bandwidth, which makes the data independent of the scripting logic, allowing multiple systems in different languages to access the data in the same way, saving valuable time spent on coding and debugging, and using predefined scenarios to perform operations , improve the query speed, and can prevent the direct interaction with the data, thereby playing the role of protecting data!

4. Details of transaction handling in PDO

Summary: A transaction (transaction) consists of a sequence of queries and/or UPDATE statements. Begins a transaction with begin, start transaction, rollback rolls back the transaction, commits the transaction. After starting a transaction, you can have several SQL queries or UPDATE statements, and after a SQL submission executes, there should be a statement that determines whether the next step is rolled back, and if it is executed correctly, the transaction is finally committed. Once a transaction is rolled back, the database remains in the pre-transaction state. As if an edited file does not save the file to exit, or to maintain the original appearance of the document. So, a transaction can be considered an atomic operation, a SQL in a transaction, or a full

5. Method of error handling in PDO two-errorinfo () method

Summary: Pdostatement::errorinfo-gets the extended error message associated with the last statement handle operation (PHP 5 >= 5.1.0, PECL PDO >= 0.1.0)!

6. Method of error handling in PDO a-errorcode () method

Summary: There are two ways to get error messages in a program in PDO: ErrorCode () method and ErrorInfo () Method! Then the next article, we will introduce you to each of these two methods!

7. Using the exception mode-pdo::errmode_exception (the error method in the capture SQL statement in PDO three)

Summary: The exception mode creates a pdoexception and sets the Erorcode property, which encapsulates the execution code into a try{...} Catch{...} Statement, an uncaught exception will cause the script to break and display a stack trace to let the user know where the problem is!

8. Use the warning mode-pdo::errmode_warning (the error method in the capture SQL statement in PDO II)

Summary: Warning mode generates a PHP warning and sets the ErrorCode property, and if you set a warning mode, the program will continue to run as it is unless you explicitly check the error code.

9. Use the default mode-pdo::errmode_silent (the error method in the capture SQL statement in PDO one)

Summary: Capturing SQL statement errors in PDO there are three options to choose from, according to your own development projects and the actual situation to choose the appropriate scenario to capture the SQL statement error!

Fetchcolumn () method of obtaining result sets in PDO

Summary: The Fetchcloumn () method is to get the value of the specified column for the next row in the result set, returning a separate column from the next row in the result set.

"Related question and answer recommendation":

PDO and thinkphp query out the data int type is also string, other frameworks like this?

PHP-Is this the PDO bug?

Python-How to encode only the Chinese in the URL

JavaScript-drop-down menu effect is the current reference to the JQ please do you have a suitable plugin?

PHP-Why is the database empty when I insert an HTML tag into the database?

Related Article

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.