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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:17:59+00:00 2026-06-13T00:17:59+00:00

I do the next query: $this->find(‘all’,array( ‘contain’ => array( ‘User’ => array(‘id’,’facebook_id’,’name’,’username’,’Author’ => array(‘first_name’,’last_name’,’code’,’photo’)),

  • 0

I do the next query:

        $this->find('all',array(
            'contain' => array(
                'User' => array('id','facebook_id','name','username','Author' => array('first_name','last_name','code','photo')),
                'Tab.code'
            ),
            'fields' => array('Comment.date','Comment.time','Comment.content'),
            'conditions' => array(
                'Tab.code' => $code
            ),
            'limit' => $limit,
            'offset' => $offset
        ));

Comment…

    public $belongsTo = array(
        'User' => array('foreignKey' => 'user_id'),
        'Tab' => array('foreignKey' => 'tab_id')
    );

User…

    public $hasOne = array('Author' => array('foreignKey' => 'id'));

and Author…

    public $belongsTo = array(
        'User' => array(
            'className' => 'User',
            'foreignKey' => 'id'
        )
    );

This returns something like this (in json)…

[
    {
        "Comment": {
            "date": "2001-12-15",
            "time": "17:32:12",
            "content": "..."
        },
        "User": {
            "id": "29",
            "facebook_id": "1234",
            "name": "User 29",
            "username": "user29"
        },
        "Tab": {
            "code": "llibre-de-prova-29",
            "id": "229"
        }
    }
    ...
]

…while I expect that attached to User appears an Author with the fields I specified. Do you know why Author doesn’t appear? I did other contains with two levels of recursivity on the code and all works as expected.

Thank you for your help and attention!

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

    Make sure that your model has the Containable behavior attached. It should include the following line:

    $actsAs = array('Containable');
    

    Pay attention to make sure that you didn’t omit an “s” in “acts” which is a common typo that is hard to spot. You can also attach the Containable behavior on the fly like this:

    $this->YourModel->Behaviors->attach('Containable');
    $this->YourModel->find('all', array('contain' => array(...)));
    

    Also make sure you type “contain” as the array key, not “contains”.

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

Sidebar

Related Questions

I need to execute this query to find out the next auto_increment value that
On the query below I keep getting this error: Cannot read the next data
This is kinda weird. I have the next query: SELECT * , GROUP_CONCAT( x.tag
in CakePHP how would go about running this query? It's to get the next
Sorry for all the dumb jquery questions I'm still learning and find this to
I want to find data with double quotes. I have the next simple query:
This is the toughest query I ever made: http://robertr.pastebin.com/X4bG4pFp SELECT `user`.`id` , `user`.`fname` ,
This is my current query: Using Java+mongoDB { BasicDBObject select = new BasicDBObject(); select.put(info.name.fn,
I have the next query that I run via SQLCMD.EXE use [AxDWH_Central_Reporting] GO EXEC
I have the next query: var bPermisos = from b in ruc.Permisos where b.IdUsuario

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.