Zebra_Database - 操作MySQL數據庫的PHP封裝

jopen 11年前發布 | 23K 次閱讀 MySQL 持久層框架

Zebra_Database 是一個高級的、緊湊的(只包含單個文件)、輕量級的、面向對象的 MySQL 數據庫訪問封裝器,基于 PHP 的  MySQL 擴展開發。提供了各種用于與 MySQL 數據庫交互的直觀方法,比 PHP 自帶的更有趣。

Zebra_Database - 操作MySQL數據庫的PHP封裝

示例代碼:

 debug = true;

$db->connect('host', 'username', 'password', 'database');

// code goes here

// this should always be present at the end of your scripts;
// whether it should output anything should be controlled by the $debug property
$db->show_debug_console();
// $criteria will be escaped and enclosed in grave accents, and will
// replace the corresponding ? (question mark) automatically
$db->select(
    'column1, column2',
    'table',
    'criteria = ?',
    array($criteria)
);

// after this, one of the "fetch" methods can be run:

// to fetch all records to one associative array
$records = $db->fetch_assoc_all();

// or fetch records one by one, as associative arrays
while ($row = $db->fetch_assoc()) {
    // do stuff
}

$db->insert(
    'table',
    array(
        'column1' => $value1,
        'column2' => $value2,
    )
);
?>

項目主頁:http://www.baiduhome.net/lib/view/home/1358732852645

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!