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
1
vote
2 answers

Customizing Containable Content in Orchard CMS

I am currently trying to understand a bit more about how Orchard handles Lists of Custom Content Types and I have run into a bit of an issue. I created a Content Type named Story, which has the following parts: Body Common Containable Route I…
Rion Williams
  • 74,820
  • 37
  • 200
  • 327
1
vote
5 answers

'Notice (8): Undefined index' in the view when looping through 'containable' results

I'm using containable to pull associated records into the view action and am getting an error message when looping through results. Also, I'm using a 'sluggable' behaviour, so the find operation has a condition to search by this variable. When I…
Paul
  • 237
  • 5
  • 24
1
vote
1 answer

Custom pagination with contains/joins and condition

I am trying to paginate some data from a model called D filtering results based on a specific condition from an indirectly related model. My models look like: D->C->B->A (where each -> is a belongs to) I want to paginate on the records of D where…
Kramer
  • 267
  • 2
  • 5
  • 13
1
vote
1 answer

How do i implement search on third level using containable behavior

I have developed a cake php application. In this there are tables like students,placements,batches,companies In placements table there is student_id,company_id and in students table there is batch_id column. In placements index page i have applied…
Pankaj Khurana
  • 3,243
  • 10
  • 50
  • 79
1
vote
1 answer

Nested Result while using CakePhp Containable

I am not sure about the question title but tried to explain more below. Thanks in advance for all who helps me. I sampled the tables to simplify my questions. DB Tables News: news_id, title Comments: comment_id, news_id, content, created…
hrnsarac
  • 27
  • 1
  • 9
1
vote
2 answers

CakePHP same result format as find('list') in Containable

I'm looking for a way to have the results of a query that uses the Containable behavior to be formatted the same way as find('list') results are. E.g.: $this->ModelA->find('all', array( 'contain' => array( 'ModelB' => array( …
lucasnadalutti
  • 5,818
  • 1
  • 28
  • 48
1
vote
1 answer

Cakephp find Item-Variants that have specific attribute

I have a problem with my Cakephp(2.6) find-query and deep association. My Relations: Item hasMany Variant Variant hasAndBelongsToMany Color I am trying to find all Items that have at least one variant with the color = blue. $options['contain'] =…
3und80
  • 364
  • 6
  • 20
1
vote
1 answer

CakePHP 3 - order on contain data not working

I am using CakePHP 3.x and I am trying to sort my data on containable data that I need for my paginator to be able to sort on it. I have the following options for my paginator: public function getEventSignupsOptionsForPagination($id) { $options…
DijkeMark
  • 1,284
  • 5
  • 19
  • 41
1
vote
2 answers

CakePHP: How can I change this find call to include all records that do not exist in the associated table?

I have a few tables with the following relationships: Company hasMany Jobs, Employees, and Trucks, Users I've got all my foreign keys set up properly, along with the tables' Models, Controllers, and Views. Originally, the Jobs table had a boolean…
Stephen
  • 18,827
  • 9
  • 60
  • 98
1
vote
1 answer

CakePHP query returns empty array where no record found in contained belognsTo model

We sell DNA tests where I need to link each OrderItem to Sample (via belongsTo association - OrderItem.sample_id). Code to retrieve OrderItem and associated model data: $data = $this->OrderItem->find('first', array( 'conditions' =>…
1
vote
2 answers

Complex ordering in CakePHP using Containable

I`m having a problem with the Containable behaviour. I would like to know if there is any way to access the contained model attributes for operations like ordering. For example, I have a model B which belongs to a Model A. I need to order objects of…
lucasnadalutti
  • 5,818
  • 1
  • 28
  • 48
1
vote
1 answer

CakePHP containable HABTM limit

According to the second sentence on the Containable Behavior section of the Cookbook, contain() supports the limit clause. A new addition to the CakePHP 1.2 core is the ContainableBehavior. This model behavior allows you to filter and limit model…
user2511309
  • 309
  • 3
  • 18
1
vote
1 answer

CakePHP repeats same queries

I have a model structure: Category hasMany Product hasMany Stockitem belongsTo Warehouse, Manufacturer. I fetch data with this code, using containable to be able to filter deeper in the associated models: $this->Category->find('all', array( …
Rytis
  • 1,447
  • 1
  • 19
  • 38
1
vote
2 answers

CakePHP - Set recursive to -1 in AppModel then use Containable behaviour as appropriate

When using CakePhp would it be advisable to set recursive = -1 in the AppModel class and then use the Containable Behaviour whenever you need a deeper data relationship? I believe this would give my applications the best chance of avoiding database…
Leo
  • 1,521
  • 12
  • 18
1
vote
2 answers

CakePhp Containable too many queries

I'm using CakePHP 2.5.2 and having a bit of trouble searching for data efficiently. In my application I've 3 tables, teams, players, skills... In teams there are 80 records, players 2400 records, skills 2400 records... I want to calculate the…