I
I
Ilya Beloborodov2016-06-24 00:26:02
Yii
Ilya Beloborodov, 2016-06-24 00:26:02

Yii1, why doesn't order work?

Here is the connection in the model

return array(
  'childs'=>[self::HAS_MANY,'Category','parent_id','order'=>'t.id_category DESC'],
);

Here is the request
$data=Category::model()->findAll([
  'with'=>[
    'childs'
  ],
  'condition'=>'t.parent_id=0',
]);

for some reason it ignores 't.id_category DESC', even if I put 't.id_category ASC' - the result will be the same

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
arab789, 2016-06-24
@arab789

Try order to write down in request.

A
Andrew, 2016-06-24
@R0dger

Do you need an alias t?
seems to just recommend

'varName'=>array('relationType', 'className', 'foreign_key', 'order'=>'column ASC')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question