Rumah > php教程 > php手册 > teks badan

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

WBOY
Lepaskan: 2016-06-21 08:51:48
asal
1075 orang telah melayarinya

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



Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!