Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id
- make_id
- model_id
- ...
- var $uses = array('Make', 'Model');
- $this->Make->id = 5; // My Make
- $this->Make->find(); // Returns only the make I want with it's Models (HABTM)
- $this->Model->find('list'); // Returns ALL models
- $this->Make->Model->find('list'); // Returns ALL models
- $makeArray = $this->Make->find();
- foreach ($makeArray['Model'] as $model) {
- $modelList[] = $model['title'];
- }
- $this->set('models', $models)
- SELECT * FROM makes, models, products WHERE make_id = 5
- SELECT models.title FROM models
- INNER JOIN products
- ON products.model_id = models.model_id
- AND products.make_id = 5
- $this->Product->find('all', array('conditions' => array('make_id' => 5)));
- $this->ModelB->find('first', array('conditions' => array('field' => $condition)));
- array(
- ['ModelB'] => array( ... ),
- ['ModelA'] => array(
- [0] => array(
- 'id' => 1
- )
- )
- $this->ModelA->find('all', array('conditions' => array('id' => $model_a_ids)));
- $habtm = " ...
- 'with' => 'MakeModel',
- ... ";
Add Comment
Please, Sign In to add comment