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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:38:51+00:00 2026-05-18T06:38:51+00:00

I’ve been banging my head against the wall with a really annoying issue. I

  • 0

I’ve been banging my head against the wall with a really annoying issue. I have two model classes:

class User extends AppModel {
    var $name = 'User';
    var $hasMany = array(
        'Application' => array(
            'className' => 'Application',
            'foreignKey' => 'user_id',
            'dependent' => false,
        )
    );
}

class Application extends AppModel {
    var $name = 'Application';
    var $belongsTo = array(
        'User' => array(
            'className' => 'User',
            'foreignKey' => 'user_id',
        )
    );
}

I want to pull Applications and the fields of User associated with it.

   $this->Applications->find();

No matter what I set $recursive to, it’s still giving me only one output:

Array
(
    [Applications] => Array
        (
            [id] => 1
            [user_id] => 3
            [datecreated] => 
            [status] => 
            [source] => 1
        )

)

On the other hand, when I pull the data from Users table with recursive set to 2, I get all the users, with their applications, WITH the user data associated with the application WITH the applications associated with the user. To put it plain and simple, here’s what I get:

Array
(
    [0] => Array
        (
            [User] => Array
                (
                    [id] => 3
                    [email] => email@email.email
                    [password] => hashstring
                    [socialsecurityno] => 21232134123
                    [role_id] => 3
                    [firstname] => Firstname
                    [lastname] => Lastname
                    [status] => 1
                )

            [Application] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [user_id] => 3
                            [datecreated] => 
                            [status] => 
                            [source] => 1
                            [User] => Array
                                (
                                    [id] => 3
                                    [email] => email@email.email
                                    [password] => hashstring
                                    [socialsecurityno] => 21232134123
                                    [role_id] => 3
                                    [firstname] => Firstname
                                    [lastname] => Lastname
                                    [status] => 1

                                    [Application] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [id] => 1
                                                    [user_id] => 3
                                                    [datecreated] => 
                                                    [status] => 
                                                    [source] => 1
                                                )

                                        )

                                )



                        )

                )

        )
)

What I want, is to get from the Applications, its associated user info, and that’s it. I’m pretty much out of ideas short of creating a habtm relationship between applications and users, which would be technically incorrect, as one user can have many applications but one application only has one user.

Right now, Applications is connected with Users via user_id in Applications table, which… should be kind of obvious, but probably should be noted anyway.

Any kind of help with this could be appreciated, I’m literally out of 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-05-18T06:38:52+00:00Added an answer on May 18, 2026 at 6:38 am

    If Model::find is called with no parameters, Cake treats it as though you made this request:

    Model::find('first',array('limit'=>1));
    

    This explains why it’s only retrieving the first Application. To retrieve all Applications, modify your call to:

    $this->Application->find('all');
    

    This doesn’t explain why Model::find is ignoring the model’s recursive setting, and, indeed, I can’t find a way to reproduce that issue, unless it’s something silly like you have typoed the model name when setting the recursion level (e.g. $this->Applications->recursive = 1;; note the pluralization of “Application”).

    Hope this helps.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.