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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:17:03+00:00 2026-06-17T10:17:03+00:00

I am using cakephp 2.1 and developing an application, which contain the following table

  • 0

I am using cakephp 2.1 and developing an application, which contain the following table structures.

1. people(id, name)
2. movies(id, name)

and ‘people’ habtm movies by tables as follows.

1. castsmovie(id, person_id, movie_id)
2. directorsmovie(id, person_id, movie_id)
3. moviesmusicdirector(id, person_id, movie_id)
4. moviesproducers(id, person_id, movie_id)
5. movieswriter(id, person_id, movie_id)
6. cinematographersmovie(id, person_id, movie_id)

I wanna fetch the movies for perticular person and paginate the movies for him.
So the code I have written is in controller

$this->paginate = array('Person' => array(
        'contain' => array(
                'CastsMovie' => array('Movie'),
                'DirectorsMovie' => array('Movie'),
                'MoviesProducer' => array('Movie'),
                'MoviesMusicDirector' => array('Movie')),
                'MoviesWriter' => array('Movie'),
                'CinematographersMovie' => array('Movie')
        ),
        'conditions' => array('Person.id' => $id)));

and the result is as follows

    array(
(int) 0 => array(
    'Person' => array(
        'id' => '101',
        'name' => 'Darshan Thoogudeep',
    ),
    'CastsMovie' => array(
        (int) 0 => array(
            'id' => '53',
            'movie_id' => '14',
            'person_id' => '101',
            'order' => '1',
            'Movie' => array(
                'id' => '14',
                'name' => 'Krantiveera Sangolli Rayanna',
            )
        ),
        (int) 1 => array(
            'id' => '78',
            'movie_id' => '19',
            'person_id' => '101',
            'order' => '0',
            'Movie' => array(
                'id' => '19',
                'name' => 'Saarathi',
            )
        ),
        (int) 2 => array(
            'id' => '137',
            'movie_id' => '35',
            'person_id' => '101',
            'order' => '1',
            'Movie' => array(
                'id' => '35',
                'name' => 'BulBul',
            )
        ),
        (int) 3 => array(
            'id' => '153',
            'movie_id' => '42',
            'person_id' => '101',
            'order' => '0',
            'Movie' => array(
                'id' => '42',
                'name' => 'Viraat',
            )
        )
    ),
    'CinematographersMovie' => array(),
    'DirectorsMovie' => array(),
    'MoviesMusicDirector' => array(),
    'MoviesWriter' => array(),
    'MoviesProducer' => array()
)
 )

But I want to fetch all movies of perticular person with limit as 20.. So that I can easily paginate the limit of movies in each page.. Please help me to get the soluting.. The work is more appreciated.

  • 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-17T10:17:04+00:00Added an answer on June 17, 2026 at 10:17 am

    I would suggest changing your data model so you have just one HABTM table:

    people_movies(id, person_id, movie_id,role_id) 
    

    You would also need a role table:

    role(id, role_name)
    

    Then you can store them all in the same table and add additional roles in future if required.

    Using this approach the query to get all movies for one person will be much simpler.

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

Sidebar

Related Questions

I am using cakephp 2.1 and developing an application which needed more data. I
I am developing an application in cakephp. In this application I am using saveAll()
I'm developing a web app using a cakephp. I've one function in which I
I'm developing a site using the CakePHP framework. I have a form which shows
I am developing an application using cakePHP v 1.3 on windows (XAMPP). Most of
  I am developing a project which is built in CakePHP and using jQuery in
I am using cakephp 2.1 and developing an application it contains more content. So
I am using cakephp 2.0 for developing a website. Site will contain only 2
I am developing one web application using CakePHP , I will be providing one
I am developing a cakephp application, I dont need to use any database tables

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.