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: Model "Comp" is not associated with model "Comp"

I am trying to do a fairly simple CakePHP find using the Containable behavior: $comp = $this->Comp->find('first', array( 'conditions' => array('Comp.id' => $id), 'contain' => array( 'Comp.id' => array( 'fields' =>…
Ben
  • 529
  • 1
  • 7
  • 9
0
votes
1 answer

Cakephp 2 use the id of the record as index when retrieving data

Is it possible to retrieve records where the index is the record id? I have a model with a hasMany Relation. So my study can have multiple texts and questions etc. The custom retrieve function looks like this: protected function…
q-jack
  • 366
  • 2
  • 3
  • 17
0
votes
1 answer

Containable won't filter 2nd level model with HABTM & hasMany

What I have: "A" HABTM "C" HABTM "A" through join table "B" "A" hasMany "B" belongsTo "A" "C" is ordered by a "B" field What I want: // result: [0] => array( A => array( /* single model's fields I still need*/ ), C => array( [0]…
Myer
  • 3,670
  • 2
  • 39
  • 51
0
votes
3 answers

CakePHP containable doesn't filter in a proper way

Like the example in cakephp manual, http://book.cakephp.org/view/1323/Containable#Containing-deeper-associations-1325, i need to fetch data from a model through a condition on its association model. I have: Model Language: class Language extends…
apelliciari
  • 8,241
  • 9
  • 57
  • 92
0
votes
1 answer

Containable fails to JOIN in belongsTo relationships when 'fields' are used in CakePHP 1.3.4

(CakePHP Version 1.3.4) I have the following association between a Contact model with Account and Test models: class Contact extends AppModel { var $name = 'Contact'; var $actsAs = array('Containable'); var $hasMany = array( …
Zubin
  • 1,015
  • 1
  • 9
  • 15
0
votes
1 answer

SQLSTATE[42S22]: Column not found when using containable and fields option in CakePHP 2.x

I am using cakephp containable behavior. I have following query $this->paginate = array( 'conditions'=>$criteria, 'contain' => array( …
0
votes
1 answer

Containable behavior does not return from depth 3 - CakePHP

I use CakePHP 1.2.6 and have the following relations: Showcase HABTM User belongsTo Galleryitem hasOne Image I try to get all the data related to a Showcase, and therefor also all its users with their Galleryitem -> Image. I use the following…
Bart Gloudemans
  • 1,201
  • 12
  • 27
0
votes
1 answer

does CakePHPs Containable-behavior support custom expressions as conditions?

Community, I'm currently facing an issue with the containable-behavior setting conditions based on the datasources expression-builder. I'm using CakePHP 2.6.2 with a PostgreSQL database. What works so far: I wrote a behavior that dynamically adds…
TurbuLenz
  • 45
  • 1
  • 9
0
votes
1 answer

In CakePHP how to make Containable behavior cooperate with Tree behavior

I have this problem with containable, that I have Categories model that behaves like a tree: class Category extends AppModel { public $actsAs = ['Tree', 'Containable']; public $hasMany = [ 'Novelty' => [ 'className' => 'Novelty', …
Sebastian Piskorski
  • 4,026
  • 3
  • 23
  • 29
0
votes
1 answer

Cakephp contain is included in query

When I run the following code the Containable behaviour does not work. I don't want to use a manual join! $data = $this->Variant->find('first', array( 'contain' => array('VariantValue'), 'conditions' => array( …
Sven Mäurer
  • 715
  • 1
  • 9
  • 19
0
votes
1 answer

cakephp contain twice model association

I have to fetch data from posts table which has foreign keys ( category_id references to categories.id created_by references to users.id, updated_by references to users.id ) I can fetch created_by username but not…
alamnaryab
  • 1,480
  • 3
  • 19
  • 31
0
votes
1 answer

It is possible to replace an inner join query by a containable in a habtm relationship?

I read the section Containable and I didn't find a clear example to replace an inner join query on a habtm relationship by a containable query. Example : Model Student hasAndBelongsToMany Teacher Teacher hasAndBelongsToMany Student Query $joins =…
Eric Lavoie
  • 5,121
  • 3
  • 32
  • 49
0
votes
1 answer

CakePHP find with "contain"

My model has many relationships to other tables/models, if i use contain parameter, for example to order by field in results of one model, all other tables in query results are missing, and must manually written in contain parameter, how can i get…
0
votes
0 answers

CakePHP containable how to do a recursion with join?

I want to retrieve tree nodes recursively and want to join each [Node] with [Level] Node: ... public $belongsTo = array( 'Parent' => array( 'className' => 'Node', 'foreignKey' => 'parent_id' ), 'Level' => array( …
jeff
  • 1,169
  • 1
  • 19
  • 44
0
votes
1 answer

How do I sort or do a find in CakePHP based on deep model associations?

I have a users table, a role_members table and a roles table. The role_members table has a user_id and a role_id because users can have many roles. I have a DataTable that has user id, email, name, and roles in it. I can easily sort and filter…
Amy Anuszewski
  • 1,843
  • 17
  • 30