0
votes

I'm having problems to get the associated model information from the cakephp shell this is my shell:

class ContactShell extends Shell{
    public $uses = array('Contact');

    public function main(){ 
        $contacts = $this->Contact->find('all', array(
                     'conditions' => array(
                   'Contact.is_sent' => false,
                   'Contact.is_bounce' => false),
                 'contain' => array('City' => array(
                           'fields' => array('City.name')))));
        debug($contacts);
    }
 }

When I run the this shell I get the error

Warning: Model "Contact" is not associated with model "City" in C:\wamp\www\togo design\cake\libs\model\behaviors\containable.php on line 363

And the results only contains the contact model array.

The same script in a controller shows me the City array

Any suggestion on how to get the associations work in the cakephp shell???

I also tried using

    $this->Contact->recursive = 1;
1

1 Answers

0
votes

Are you adding the Containable Behavior to Contact Model?

public function main(){ 
    $this->Contact->Behaviors->attach('Containable');
    $contacts = $this->Contact->find('all', array(
                 'conditions' => array(
                     'Contact.is_sent' => false,
                     'Contact.is_bounce' => false),
                 'contain' => array('City' => array(
                       'fields' => array('City.name')))));
}

If this doesn't work we would need to see the definition of your Contact Model