PHP 访问 MySQL 的封装 - Zebra_Database 2.7 发布
webphp 13年前
<p><a href="/misc/goto?guid=4958189022348816236" target="_blank">Zebra_Database </a>是一个高级的、紧缩的(只包含单个文件)、轻量级的、面向对象的 MySQL 数据库访问封装器,基于 PHP 的 MySQL 扩展开发。提供了各种用于与 MySQL 数据库交互的直观方法,比 PHP 自带的更有趣。<br /> Zebra_Database 2.7 发布,该版本新增使用 memcached 缓存查询结果的功能,修复了一些 bug。<br /> </p> <p>示例代码:<br /> </p> <pre class="brush:php; toolbar: true; auto-links: false;"> 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, ) );</pre> <p></p> <p></p> <p><img style="width:543px;height:350px;" alt="PHP 访问 MySQL 的封装 - Zebra_Database 2.7 发布" src="https://simg.open-open.com/show/281e264ca6cb1843c7a31c9e168bb7c8.gif" /></p>