|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
培训的第二阶段,开始了PHP语言语法结构和应用的学习。
其实这个框架的所谓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 < ?", $pages);
$books = $m->find("from book as b where b.title like ? and b.pages < ?", $title, $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大家如果能懂得“熟能生巧”的道理也就明白了这并不是浪费时间,同时这也可以减轻板主的负担,让他们有时间去处理更难的问题。 |
|