首页 > php教程 > php手册 > orm框架:php orm框架ezpdo(2)之ezpdosql

orm框架:php orm框架ezpdo(2)之ezpdosql

WBOY
发布: 2016-06-21 08:51:48
原创
1108 人浏览过

其实这个框架的所谓ezpdosql就是hibernate的hsql咯,没啥的,所以照罗列一次,没啥特别的
首先是from子句
$m = epmanager::instance();
$books = $m->find("from book as b where b.title = ?", $title);
//like的例子
$books = $m->find("from book as b where b.title like 'intro%'");
// null的例子
$books = $m->find("from book as b where b.title is null");
$books = $m->find("from book as b where b.pages $books = $m->find("from book as b where b.title like ? and b.pages 之后是支持in参数了
$books = $m->find("from book as b where b.price in (2.50, 100.01)");
$books = $m->find("from book as b where b.author.name in ('joe smith', 'jane smith')");
in里面也支持数组
books = $m->find("from book as b where b.price in (?)", array(2.50, 100.01));
$books = $m->find("from book as b where b.author.name in (?)", array('joe smith', 'jane smith'));
当然要支持sort和limit了
// find books and sort by book id (default ascending order)
$books = $m->find("from book as b where b.title like ? order by b.id", $title);
// find books and sort by id in ascending order
$books = $m->find("from book as b where b.title like ? order by b.id asc", $title);
// find books and sort by id in desscending order
$books = $m->find("from book as b where b.title like ? order by b.id desc", $title);
// find books and sort by id in desscending order and limit to the first two only
$books = $m->find("from book as b where b.title like ? order by b.id desc limit 0, 2", $title);
支持以下的聚合函数
avg(),
count(),
max(),
min()
sum()
例子
$cost = $m->find("sum(price) from book where title like '%php%'");
$num_pages = $m->find("sum(pages) from book where title like '%php%'");
$num_books = $m->find("count(*) from book where title like '%php%'");
$cost_per_page = $cost/$num_pages;
$cost_per_book = $cost/$num_books; 本文链接http://www.cxybl.com/html/wlbc/Php/20120531/27130.html



相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板