Compared with ADODB and MDB2, PDO is more efficient. For now, implementing the "Database Abstraction Layer" is a great way to go, and using a database access abstraction layer like PDO is a good choice.
Pdo->begintransaction ()-Indicates rollback start point
Pdo->commit ()-Indicates the rollback end point and executes the SQL
Pdo->__construct ()-Create an instance of a PDO linked database
Pdo->errorcode ()-Get the error code
Pdo->errorinfo ()-Get the wrong information
Pdo->exec ()-Processes an SQL statement and returns the number of entries affected
Pdo->getattribute ()-Get a property of a "Database connection object"
Pdo->getavailabledrivers ()-Get a valid PDO drive name
Pdo->lastinsertid ()-Gets the primary key value of the last piece of data written
Pdo->prepare ()-Generate a "query object"
Pdo->query ()-Processes an SQL statement and returns a "Pdostatement"
Pdo->quote ()-add quotation marks to a string in a SQL
Pdo->rollback ()-Perform a rollback
Pdo->setattribute ()-Set properties for a database connection object
Pdostatement->bindcolumn ()-bind a column to a PHP variable
Pdostatement->bindparam ()-binds a parameter to the specified variable name
Pdostatement->bindvalue ()-binds a value to a parameter
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, from the next row of a result set
Pdostatement->fetchobject ()-fetches the next row and returns it as an object.
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
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
As you can see from the list of functions, the operation is based on a different object, and "PDO" represents a database connection object (the new PDO produces), and "Pdostatement" represents either a query object (Pdo->query ()) or a result set object (pdo- >prepare () produced).
An example of a "Database connection object", return "PDO":
Copy Code code as follows:
<?php
$DBH = new PDO (' Mysql:host=localhost;dbname=test ', ' root ', ');
?>
An example of a "query object" that returns "Pdostatement":
Copy Code code as follows:
<?php
$sql = "INSERT into ' test '. ' Table ' (' Name ', ' age ') VALUES (?,?);";
$stmt = $dbh->prepare ($sql);
?>
An example of a result set object that returns "Pdostatement":
Copy Code code as follows:
<?php
$sql = "SELECT * from ' table ' WHERE ' name ' = ' Samon '";
$stmt = $dbh->query ($sql);
?>
Current 1/2 page
12 Next read the full text