Home  >  Article  >  php教程  >  orm框架:php orm框架ezpdo(2)之ezpdosql

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

WBOY
WBOYOriginal
2016-06-21 08:51:481075browse

其实这个框架的所谓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



Statement:
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