Search code examples
symfony1propel

Order by difference between 2 columns of


I have a mysql query to oreder by using difference of two fields of same table

SELECT *
FROM postings
ORDER BY vote_up - vote_down;

its working

How i write this query using propel criteria,

I write like this $criteria->addDescendingOrderByColumn(self::VOTE_UP-self::VOTE_DOWN)

but it makes errors. Anybody know please help.

Help is highly appreciated.

Thanks,


Solution

  • Try:

    $criteria->addDescendingOrderByColumn(self::VOTE_UP.' - '.self::VOTE_DOWN)