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 Containable: Same model in deep association

I searched quite some for this, but I don't even know what to call it. In a simplified version, I have these Models: Person (id, name) - hasMany: ArrivalDate Country (id, name) - hasMany: Person ArrivalDate (id, arrival_date, salesman_id) -…
mtwell
  • 33
  • 6
0
votes
1 answer

CakePHP containable for join not searching additional table

I'm trying to join two tables and I found this post on accomplishing it using containables. The tables I'm trying to join are orders and order_items. Here's the code in my Order and Order_Item controller Class OrderItem extends AppModel { public…
user2443591
  • 127
  • 4
  • 16
0
votes
1 answer

Creating complex conditions with CakePHPs paginate and containable behavior

I'm using the containable behavior to look at several tables. $this->paginate = array( 'contain' => array( 'Co' => array('fields' => array('ref')), 'CoItemType' => array('fields' => array('name')), …
cnizzardini
  • 1,196
  • 1
  • 13
  • 29
0
votes
1 answer

How do I get CakePHP 2.2.4 to contain and return data for 4th level association?

I have four models (Location->StatisticCategory->StatisticItem->Statistic) that I'm trying to return in a single query. The results are as expected until the query starts at the level of Location. At that point the data return contains everything…
jRoB
  • 338
  • 1
  • 9
0
votes
1 answer

CakePHP containable behaviour not firing

First time using Cake and its containable behaviour, but it's not working as expected ... or at all. I'm trying to obtain a list of accessories for a product. Product model HABTM products (alias 'ProductRelation'). Join table is products_products…
tremendusapps
  • 108
  • 1
  • 13
0
votes
1 answer

Containable "contain" property not being reset

Containable is not behaving as I expect in CakePHP 2.1.2 in the following code: class ReportCard extends AppModel { .... // debug shows expected results public function test1(){ $this->Behaviors->attach('Containable'); …
Rob
  • 21
  • 1
0
votes
3 answers

CakePHP Containable behaviour not working as expected

I'm trying to retrieve specific fields from a model that is 2 levels deep. Im using the container behaviour but the bottom level is not being retrieved properly. Heres the code: $this->Review->Behaviors->attach('Containable'); $latestReviews =…
cowls
  • 24,013
  • 8
  • 48
  • 78
0
votes
2 answers

CakePHP Filtering associated model by array

I have models: Project=>Keyword using HMBTM relationship (set in both models). The keywords table acts as a Tree, ie. the keywords have hierarchical relationship amongst themselves. I am using containable behavior. A user selects a keyword. I want…
Paul Snell
  • 33
  • 2
  • 8
0
votes
4 answers

CakePHP Containable error: a two level association doesn't work

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' …
dgnin
  • 1,565
  • 2
  • 20
  • 33
0
votes
1 answer

Cakephp 2 Containable doesnt filter properly

I'm not sure if I'm doing something bad or this is actually the expected behaviour from Cake. The following is my code: $tickets = $this->TicketsPrice->Ticket->find('all',array( 'contain'=> array( 'TicketsType' =>…
capsula
  • 498
  • 1
  • 7
  • 21
-1
votes
2 answers

Deep Associations works with recursive => 2 but too slow to load

I have 3 models Product having product_family_id as foreign key to ProductFamily and ProductFamily have customer_id as foreign key to Customer. Putting recursive to 2 in Product model allow me to get Customer name from Customer for a product. But…
-3
votes
2 answers

SQL query to CakePHP translation

I have been trying to figure out this (I guess really simple) thing for several days: I have three tables with these fields: alumnes: id, nomcognoms grups: id alumnesgrups: id, alumne_id (related to Alumnes.id) and grup_id (related to Grups.id).…
1 2 3 4 5 6 7
8