欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2024-01-30 23:05:22
...
其实这个框架的所谓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