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 9000789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:21:14+00:00 2026-06-16T00:21:14+00:00

To explain the issue I’m having, I’ll use an example. Let’s say that I’m

  • 0

To explain the issue I’m having, I’ll use an example. Let’s say that I’m building a system where students can sign up for an afterschool class, but an administrator has to approve the sign-up in order for it to be valid. So I have these models:

  • Calendar (belongs to “Teacher”, hasAndBelongsToMany “Student”)
  • Student (hasAndBelongsToMany “Calendar”)
  • Teacher (hasMany “Calendar”)

Now let’s say I want to see a list of all of the unapproved sign-ups that are for ninth-graders. I want the list to include the calendar date, the student’s name, and the teacher’s name. I would do something like this:

$this->request->data = $this->Student->CalendarsStudent->find('all', array(
    'conditions' => array(
        'CalendarsStudent.is_approved' => null,
        'Student.grade' => 9
    )
));

The problem with the above code is that the returned array is missing the teacher’s name:

Array
(
    [0] => Array
        (
            [CalendarsStudent] => Array
                (
                    [id] => 1274
                    [calendar_id] => 200
                    [student_id] => 872
                    [is_approved] => 
                )

            [Calendar] => Array
                (
                    [id] => 200
                    [date] => 2012-12-17
                    [teacher_id] => 1
                    [total_slots] => 15
                )

            [Student] => Array
                (
                    [id] => 872
                    [teacher_id] => 1
                    [first_name] => Billy
                    [last_name] => Smith
                    [grade] => 9
                )

        )

)

If I add 'recursive' => 2 to the find parameters, I get way too much information. $this->request->data[0]['Calendar'] will have [Teacher], which is what I want, but it will also have [Student], which I don’t want. Also, $this->request->data[0]['Student'] will have subarrays that I don’t want. It seems like Containable would fix this, but I can’t get that to work either.

Any ideas?

  • 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-16T00:21:15+00:00Added an answer on June 16, 2026 at 12:21 am

    Use CakePHP’s [Containable Behavior]. It’s amazing – easy to use and will return whatever you want it to.

    Side note: If you’re using “recursive” as anything other than -1 for ANYTHING, it should be a red flag. Containable is the absolute way to go as it lets you specify easily and exactly what data you want returned. Recursive will often cause memory issues and or other badness.

    Best practice IMO: set $recursive = -1; in your AppModel.php and never set it to anything else…ever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could barely find a reasonable title that would explain my issue, let alone
Alright. I'm new to jEditable. Let me explain the issue i'm having with jEditable.
Can someone explain this issue to me ? I have a listview that holds
it's a hard to explain issue so i hope i can state it i
Perhaps a confusing title but let me explain the issue through steps: I have
I will explain my issue using an example: A=[[1,2,10],[1,2,10],[3,4,5]] B=[[1,2,30],[6,7,9]] From these lists of
I hope this helps explain the issue I am having I have recently designed
Hi everyone let me explain this issue: Background: I have two web applications The
I can't explain an issue I've run across. Basically I get a different answer
Let's first start with a code snippet to explain the issue: = Haml::Engine.new('#bar= yield').render

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.