Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

SQL sentece with Group By using fRecordset::build

posted by ramascaro 8 years ago

Hello everybody!

I would like to get info from database with this SQL sentence but I want to do this without writing SQL

SELECT pe.id, pe.lastname, pe.name, sum( pa.amount )
FROM people pe
INNER JOIN payments pa ON pe.id = pa.id
WHERE pa.status =0
GROUP BY pe.id, pe.lastname, pe.name
ORDER BY pe.lastname, pe.name

I would like to use fRecordSet::build(...) method, not writing SQL using fRecordSet::buildFromSQL(...).

Is this possible? How can I do that?

Thanks!

Unfortunately fActiveRecord strictly represents a single row from a database table. Because of this you aren't going to be able to get the results of the above SQL query without writing SQL.

You can use fResult::unescape() and fResult::asObjects() to get nice clean stdClass objects back from fDatabase/fResult, you just wouldn't get all of the extra ORM functionality.

posted by wbond 8 years ago

I supposed it could not be possible without writing SQL, but I posted it to confirm that.

Thanks wbond! Too quick, too clear.

posted by ramascaro 8 years ago