NotORM 联表查询

易毛毛 发布于 2014/08/22 11:32
阅读 550
收藏 0

@梦函 你好,想跟你请教个问题:

  NotORM 中 怎么 使用联表查询 

   sql 如下 :

    select P.UserID as userid,sum(G.Num*G.Money) as rank from PayData as  P

    left join GoodsInfo as G on P.GoodsInfoID = G.id

    where P.Time between 140850000 and 1900000000 group by P.UserID order by rank desc

  对于转换为  NotORM 就 不会了,下面是我装的,执行不出结果,能否帮我看下。

       $software->PayData()->select('PayData.UserID as userid' ,' sum( GoodsInfo.Num * GoodsInfo.Money) as rank ')->where('PayData.GoodsInfoID =?',' GoodsInfo.id')->where('PayData.Time > ? AND PayData.Time < ? ',140850000 ,1900000000)->group('PayData.UserID')->order('rank DESC');

Thanks 

加载中
返回顶部
顶部