Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to order by multiple columns with propel

I need to sort a query by 2 columns. Is this possible using propel?

i tried:

$c->addAscendingOrderByColumn(self::COL1);
$c->addAscendingOrderByColumn(self::COL2);

but the second call to addAscendingOrderByColumn overrides the first one.

Regards, Radu.

like image 887
Radu Dragomir Avatar asked Dec 21 '22 19:12

Radu Dragomir


1 Answers

I was struggling with this issue and after reading this post I have been almost gave up... but suddendly I found this solution:

$criteria->addAscendingOrderByColumn(ClassPeer::COLUMN1)->addAscendingOrderByColumn(ClassPeer::COLUMN2);

In this way the second call to addAscendingOrderByColumn will add the order to the first one.

like image 103
macgyver Avatar answered Dec 30 '22 16:12

macgyver