Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Odd ordering result with ORM related query
  • I saw the post from the other day but I believe I'm running to a different problem. For whatever reason when I'm trying to find models if I set a condition on a related table the ordering comes out different if there is a limit imposed. The ORM query looks like this
      $posts = Model_Post::find()
                    ->where('user_network.network_id', $id)
                    ->order_by('created_at', 'desc')

    If run that, then the output is very odd it looks like it orders the results by the user and then the time the main model was created. Now If I take out there where conditional it orders everything correctly. OR if I take out the limit everything is also ordered correctly, but with both I dont know whats going on. Also it seems to be fetching the right rows, but they're just jumbled up. Am I missing something with with ORM and limits & relations?
  • Could you replace ->get() with ->get_query() and echo the output (you'll get a Database_Query instance which can be cast to string to get the SQL). That'll help in determining if something is wrong.
  • Hey sorry it took me a while to get back thanks for responding, I made sure to pull the lastest ORM package and rewrote the code and things seem to be working now, I may have been passing a null variable into the offset method which was most likely the culprit

Howdy, Stranger!

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

In this Discussion