Questions tagged [containable]

Containable is a core CakePHP behaviour for filtering and limiting model find queries.

Containable is a core CakePHP behaviour for filtering and limiting model find queries. It works by binding and unbinding models on the fly, and results in a filtered, efficient result set that can cut down on memory and database resources.

View the official documentation on the Containable behaviour.

117 questions
0
votes
1 answer

Cakephp find containable / linkable by Group

I have 3 models in a cakephp 2.1 application Label, Category, Product. Product is associated with Category & Label through a hasOne relationship. What is the most efficient way using containable or linkable to achieve the following data…
Chris
  • 73
  • 1
  • 6
0
votes
1 answer

Cakephp and Containable error

I have the containable behavior in my appModel. When I do this in my Asset model: $this->Asset->contain(); $this->find..... I'm getting the following error: Fatal error: Call to a member function contain() on a non-object However, when I use…
Kdigital
  • 3,795
  • 3
  • 28
  • 24
0
votes
2 answers

CakePHP Filtering Based on Associated Data with Pagination

Here is my scenario: I have two tables: subfirms and subfirmdetails. I am trying to paginate the subfirms but with filters depending on certain subfirmdetail values, such as AUM (total money at a firm). Here is my pagination code:…
jwg2s
  • 806
  • 1
  • 12
  • 25
0
votes
2 answers

cakePHP containable model should not be empty

I have problem in filtering records, I don't want any records have empty models. $this->paginate = array('fields' => array('DISTINCT Joborder.id', 'Joborder.job_type', 'Joborder.payment_status', …
msmohan
  • 27
  • 9
0
votes
2 answers

CakePHP Containable error

I am trying do a find statement to get the content accordingly users(id, name, city_id) visitors(id, user_id, visitor_id) // visitor_id also refers to users table cities(id, name) PHP $visitor_data = $this->User->Visitor->find('all', array( …
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
0
votes
1 answer

Can I use subqueries in a 'containable' condition?

In my CakePHP I have ModelA which hasMany ModelB. ModelB has an int value Q. Can I query ModelA and use containable to ensure that only those ModelB records with the maximum value for Q? I've tried this: $this->ModelA->contain(array( 'ModelB.Q…
Tom Wright
  • 11,278
  • 15
  • 74
  • 148
0
votes
1 answer

CakePHP: the very basics of Containable

I read much about how great containable is. Honestly I have read all docs, I have it working in my Users controller, but some things are not clear: Do I have to use it in All actions or only in Index()? Do I have to define it in every controller…
ChrisDK
  • 243
  • 1
  • 6
  • 14
0
votes
2 answers

CakePHP, Containable, Group By

I've got a scenario where I am trying to use group by on a model associated with my main model using containable. Here is my output: Array ( [Subfirm] => Array ( [id] => 1 [firm_id] => 1 [name] =>…
jwg2s
  • 3
  • 2
0
votes
1 answer

CakePHP and Containable

Let me start out by saying I've tried to read the CakePHP book as much as I can for this particular topic, and for whatever reason, I just cannot figure this out. I have a few models: Person each person can have many jobs each job has one branch…
jwg2s
  • 3
  • 2
0
votes
2 answers

Trying to get "City" data from Event->Venue->City using 'contain' in CakePHP

I'm trying to return a list of events, and include the city where it's taking place. The city is only associated through the Event's Venue though. Below is the code I'm using. It returns all the correct data, but it doesn't return ANY city data…
Dave
  • 28,833
  • 23
  • 113
  • 183
0
votes
3 answers

cakephp contain

I have a problem with contain :( , let me explain: Models Relations: Client -> hasMany -> Card -> hasAndBelongsToMany -> Partner -> hasMany -> Contact What i need is to get all partners and contacts of Client with codigo = 24150 and Contacts with…
Rui
  • 516
  • 3
  • 8
0
votes
1 answer

CakePHP 2.0 containable returning unexpected result

I have the following class and associated database structure class OrganisationAccount belongsTo Account belongsTo Organisation class Account hasOne User class Organisation belongsTo Account class User belongsTo Account I'm…
Prathamesh Datar
  • 375
  • 1
  • 4
  • 20
0
votes
1 answer

Cakephp3 Sumof Containable Data

I have an Articles model and Ratings model. An Article hasMany Ratings. I want to find the 10 highest rated Articles in the past 60 days.. The problem as I see it is that i have to get the sumOf 'score' on a containable model. This is what I have…
Alan A
  • 2,557
  • 6
  • 32
  • 54
0
votes
1 answer

Cakephp 2.x - Containable refusing to work

I have the following Model structure: Models: Opening Application Applicant Group The first three was created on initial setup of the application, with Groups added via the bake script afterwards. Model associations: Applicant hasMany…
Sollie
  • 367
  • 1
  • 3
  • 9
0
votes
1 answer

CakePHP Ignoring Containable With Pagination?

I want to have cakephp paginate data and still use containable, but for some reason it seems to ignore my pleas to contain anything and just gives me back the entire Tenant row. In my TenantsController I have the following code: $conditions =…
user559540