php pdo orm,orm框架:php orm框架ezpdo(2)之ezpdo_php

其实这个框架的所谓ezpdosql就是Hibernate的hsql咯,没啥的,所以照罗列一次,没啥特别的

首先是from子句

$m = epmanager::instance();

$books = $m->find("from book as b where b.title = ?", $title);

//like的例子

http://www.gaodaima.com/?p=50130orm框架:php orm框架ezpdo(2)之ezpdo_php

$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

欢迎大家阅读《orm框架:php orm框架ezpdo(2)之ezpdo_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码

e7ce419cf2d6ad34d01da2ceb8829eed.png

微信 赏一包辣条吧~

023a57327877fb4402bcc76911ec18ea.png

支付宝 赏一听可乐吧~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值