Zebra_DatabasePHP的MySQL擴展
Zebra_Database 是一個高級的、緊縮的(只包含單個文件)、輕量級的、面向?qū)ο蟮?MySQL 數(shù)據(jù)庫訪問封裝器,基于 PHP 的 MySQL 擴展開發(fā)。提供了各種用于與 MySQL 數(shù)據(jù)庫交互的直觀方法,比 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,
)
);
?>評論
圖片
表情
