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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:26:46+00:00 2026-06-12T01:26:46+00:00

The Scenario: I have a CakePHP App, With a Plugin called Fruit. The Fruit

  • 0

The Scenario: I have a CakePHP App, With a Plugin called Fruit. The Fruit Plugin contains a route to the TagsController.php with an Action of index which points to index.ctp

The Tags Model has one association. user_id

The Problem: Even with me adding a joins option to the Model->find(‘all’… the [‘User’] index is undefined. I am not sure what to do, here is my code….

TagsController

public function index($ajax = false) {
    $this->Tag->recursive = 2;
    $tags = $this->Tag->find('all', array('conditions' => array('User.id' => $this->Auth->user('id')), 'joins'=>array(
    array(
         'table'=>'users',
         'alias'=>'User',             
         'conditions'=>array(
              'User.id=Tag.user_id'
         )
    ),
    )));

    print_r($tags);

    $this->set('tags', $this->paginate());

    if($ajax == 'ajax')
    {
        $this->layout = 'ajax';
    }
}

Tags Model

App::uses('FruitAppModel', 'Fruit.Model');
class Tag extends FruitAppModel {

public $name = 'Tag';
public $uses = array('User');
public $belongsTo = array(
    'User' => array(

        'className' => 'User',
        'foreignKey' => 'user_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

User Model

App::uses('AppModel', 'Model');

class User extends AppModel {

public $name = 'User';
public $displayField = 'username';

public $hasMany = array(        
    'Tag' => array(
        'className' => 'Fruit.Tag',
        'foreignKey' => 'tag_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    ),

);

I have been stuck on this problem for several hours now, so any fresh ideas on what I can try are greatly appreciated. I have combed through stackoverflow pretty good and I am just going in circles, I need a fresh pair of eyes on this. Any ideas at all would be awesome.

Thank you!

  • Jeff
  • 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-12T01:26:47+00:00Added an answer on June 12, 2026 at 1:26 am

    I think you have tried a lot and made it more complicated, try this code it will give you desired output.

    in user model:

    public $hasMany = array(        
    'Tag' => array(
        'className' => 'Fruit.Tag',
        'foreignKey' => 'user_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    ),
    

    in controller:–

    $this->Tag->recursive = 1;
    
     $this->paginate = array(
        'conditions' => array('Tag.user_id' => $this->Auth->user('id'))
    );
    $data = $this->paginate('Tag');
    pr($data);
    $this->set(compact('data'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an app with cakephp 1.3. I have a scenario where the
Scenario: I have a page which contains a dropdownlist and a table which contains
Scenario I have a Sinatra App I have a route that fetches articles based
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
Scenario : I have a PHP Forum and a Asp.Net site hosted on Linux
Scenario :- I have to call MYSQL stored procedure from PHP and do some
Scenario: I have got a client, php script and a MySQL database. I am
Scenario: I have a string of hexadecimal characters which encode 8-bit signed integers. Each
Scenario: I have an application that has a config table which stores the config
Scenario: I have a Question which has 2 radio buttons & two subforms: subformA

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.