Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how to create Sum, avg function in ORM Chaining query
  • like count and min , max , I am trying to use sum and max query in the orm chaining query but i am geting an error in to it. can u tell me is their any way to use sum and avg in orm query or we can not use this in orm
  • HarroHarro
    Accepted Answer
    The answer is: it depends.

    ORM only supports these methods on a total result, like $model->count(); or $model->max('amount'); As ORM doesn't support partial or custom selects, it doesn't support these SQL statements as part of the select.

    So you can't inject a "MAX(column) AS MaxValue" into a select of a get() operation. It is not what an ORM is made for, it's not a query builder. So if you have complex questions, use DB.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion