Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
columns passed to order_by are getting rearranged when fetching results
  • Hi, I am trying to run an ordering on a related select where I want to order by a related table field and then fields in the main table: Using code similar to:
    Model_Post::query()->related('comments')->order_by('comments.user_id')->order_by('publish_date'); I would expect a query to be generated with an order clause similar to:
    ORDER BY comments.user_id ASC, posts.publish_data ASC However, its ALWAYS wanting to sort the main tables columns first so I get
    ORDER BY post.publish_date ASC, comments.user_id ASC And well...thats not the ordering I want / expect to be run. I've also tried rearranging the order I call the order_by() functions and using an array of columns to be ordered and passed these in both directions. Does anyone know why it needs to do the sorting in this order? Or is this a bug / can someone fix it?
    Thanks, Richard
  • I can confirm this is happening,, even with the latest version. Thanks!!
  • Report and discuss bugs on github, this one was reported and will be fixed once I have time for it or someone else bothers to look into it: https://github.com/fuel/orm/issues/134

Howdy, Stranger!

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

In this Discussion