Home > php教程 > php手册 > 基于TP的灵感,用PDO类封装了一个链式Model底层

基于TP的灵感,用PDO类封装了一个链式Model底层

WBOY
Release: 2016-06-07 11:34:20
Original
1637 people have browsed it

完整的链式封装已经完成,并且用在了我最近开发的小型框架——JunPHP中作为Model模型底层。这样就将其中最简单的一部分查询操作先开源给大家学习下
/*
链式操作一般有:
where 查询条件
field 指定查询结果集中的返回字段
order 排序
limit 限制查询结果

结尾方法:
select 执行查询返回二维数组
find 执行查询,只能返回一条数据,返回一维数组
*/

$db = new Model();
$res = $db->M('article')->order('id desc')->select();//返回查询结果的二维数组
$res = $db->M('article')->order('id asc')where('id=3')->find();//返回查询结果的一位数组,只能返回一条记录

下载地址:http://www.im158.com/zhishi-Showz-pid-40-id-48.html

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template