色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP PDO函數庫(PDO Functions)第1/2頁

與ADODB和MDB2相比,PDO更高效。目前而言,實現“數據庫抽象層”任重而道遠,使用PDO這樣的“數據庫訪問抽象層”是一個不錯的選擇。
PDO->beginTransaction() ― 標明回滾起始點
PDO->commit() ― 標明回滾結束點,并執行SQL
PDO->__construct() ― 建立一個PDO鏈接數據庫的實例
PDO->errorCode() ― 獲取錯誤碼
PDO->errorInfo() ― 獲取錯誤的信息
PDO->exec() ― 處理一條SQL語句,并返回所影響的條目數
PDO->getAttribute() ― 獲取一個“數據庫連接對象”的屬性
PDO->getAvailableDrivers() ― 獲取有效的PDO驅動器名稱
PDO->lastInsertId() ― 獲取寫入的最后一條數據的主鍵值
PDO->prepare() ― 生成一個“查詢對象”
PDO->query() ― 處理一條SQL語句,并返回一個“PDOStatement”
PDO->quote() ― 為某個SQL中的字符串添加引號
PDO->rollBack() ― 執行回滾
PDO->setAttribute() ― 為一個“數據庫連接對象”設定屬性
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 column 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 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”表示的是一個數據庫連接對象(new PDO產生),“PDOStatement”表示的是一個查詢對象(PDO->query()產生)或者是一個結果集對象(PDO->prepare()產生)。
一個“數據庫連接對象”的例子,返回“PDO”:
復制代碼 代碼如下:
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', '');
?>

一個“查詢對象”的例子,返回“PDOStatement”:
復制代碼 代碼如下:
<?php
$sql = "INSERT INTO `test`.`table` (`name` ,`age`)VALUES (?, ?);";
$stmt = $dbh->prepare($sql);
?>

一個“結果集對象”的例子,返回“PDOStatement”:
復制代碼 代碼如下:
<?php
$sql = "SELECT * FROM `table` WHERE `name` = 'samon'";
$stmt = $dbh->query($sql);
?>

php技術PHP PDO函數庫(PDO Functions)第1/2頁,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 二手房| 溧水县| 陆丰市| 西贡区| 彰化县| 汽车| 安新县| 茌平县| 崇仁县| 柏乡县| 寿阳县| 都兰县| 哈巴河县| 英吉沙县| 来宾市| 尉犁县| 周口市| 西乌珠穆沁旗| 广河县| 游戏| 望江县| 霍山县| 冕宁县| 老河口市| 镇远县| 大足县| 汝州市| 常州市| 锡林浩特市| 长武县| 麻江县| 秭归县| 怀远县| 运城市| 内黄县| 札达县| 海淀区| 宁城县| 准格尔旗| 饶平县| 会泽县|