Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:46:42+00:00 2026-06-08T18:46:42+00:00

I know how to sort the primary model using the ‘order’ option. But how

  • 0

I know how to sort the primary model using the ‘order’ option. But how do I sort associated data?

Ok, I tried this:

$task = $this->Task->read(null, $id, array('order' =>
        array('Subtask.completed ASC')
));

Then I found out that read doesn’t have an option parameter. So I tried setting a variable for the other model, so I could use the option in the find method:

$subtasks = $this->Subtask->find('all', array('conditions' => array(
        'Subtask.task_id' => $id),
        'order' => array('Subtask.completed ASC')
));

Which got me the following error:

Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\taskExplorer\app\controllers\tasks_controller.php on line 54

So a solution to the problem might be to bind in a second model (Subtask) so I can use it for find. But I don’t know how to do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:46:45+00:00Added an answer on June 8, 2026 at 6:46 pm

    Try this :

    $this->loadModel('Subtask');
    $subtasks = $this->Subtask->find('all', array('conditions' => array(
        'Subtask.task_id' => $id),
        'order' => array('Subtask.completed ASC')
    ));
    

    And if you have defined relationship in model then you can access it like:

    $subtasks = $this->Task->Subtask->find(
                                 //rest of code
                               );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this sort of code is not best practice, but nevertheless in certain
I know that this sort of question has been asked here before, but still
I know how to sort Core Data objects in a tableview by NsDate, but
(I know this is a sort of lazy question, but it's oddly hard to
I know bubble sort is probably not the fastest way to do this but
I know that The Treeset Sort the input automatically but don't accept duplicates.Is there
I am using the new ADO.NET Entity Data Model on a simple database. I
I know that the primary key in InnoDB is clustered. So that using an
I have this code on my header (I know sort of bad practice): ?>
does anyone know any sort of app that lets users visit a page on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.