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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:40:40+00:00 2026-06-03T05:40:40+00:00

greatings! my models are not being configured as containable. this following query dont display

  • 0

greatings!
my models are not being configured as containable. this following query dont display the correct result (i want to retrieve all the available cars between two dates in all category)

$car=$this->Genre->find('all', array(
                            'contain' => array(
                                'cars'=>array(
                                    'conditions'=>array(
                                        'cars.startdate <=' => $qdu ,
                                        'cars.enddate >=' => $qau
                                    )
                                )
                            )
                        )
                    );

this is my Genre model:

class Genre extends AppModel {
       public $actsAs = array('Containable');

    public $belongsTo = array(
    'houses' => array(
        'className' => 'houses',
        'foreignKey' => 'houses_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

public $hasMany = array(
    'cars' => array(
        'className' => 'cars',
        'foreignKey' => 'genres_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

}

and this is car model:

class Car extends AppModel {

    public $belongsTo = array(
    'Genres' => array(
        'className' => 'Genres',
        'foreignKey' => 'genres_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

public $hasMany = array(
    'ways' => array(
        'className' => 'ways',
        'foreignKey' => 'cars_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

}

  • 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-03T05:40:41+00:00Added an answer on June 3, 2026 at 5:40 am

    Model names should normally be singular, so “Car” instead of “cars”.

    $car=$this->Genre->find('all', array(
                                'contain' => array(
                                    'Car'=>array(
                                        'conditions'=>array(
                                            'Car.startdate <=' => $qdu ,
                                            'Car.enddate >=' => $qau
                                        )
                                    )
                                )
                            )
                        );
    

    Also, make sure the Genre model loads the Containable behaviour.

    class Genre extends AppModel {
       $actsAs = array('Containable');
    }
    

    Associations should also use singular, capitalised model names:

    class Genre extends AppModel {
      public $actsAs = array('Containable');
    
      public $belongsTo = array(
        'House' => array(
            'className' => 'House',
            'foreignKey' => 'houses_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
      );
    
      public $hasMany = array(
        'Car' => array(
            'className' => 'Car',
            'foreignKey' => 'genres_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
      );
    }
    

    It’s a Cake convention to have pluralised controllers (CarsController, GenresController) and singular models (Car, Genre). When defining associations you’re in essence linking models together and not controllers, hence the need for singular, capitalised classnames.

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

Sidebar

Related Questions

Greetings, I am trying to tear down query returned from find call using containable
Greetings, Apologies in advance that I have not researched this toughly enough to answer
Greetings On all my controllers I recycle the same code that wraps my models
Grettings!. I am having too much troubling with the following question... i will try
Greetings, I am trying to learn pointers in C, I simply want my addtwo
Greetings, how can I inject c# code (my Model property) inside javascript? I want
Greetings Having an ImageField object in my Foo model as such: class Foo(models.Model): name
I've spent far too much time with this and can't find the mistake. Maybe
Greetings, in Magento I want to trigger an event, once an order has been
Greetings, I have these 2 models: from django.db import models class Office(models.Model): name =

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.