Frage

Ich versuche, einen ziemlich einfachen CakePHP Fund mit dem Contain Verhalten zu tun:

$comp = $this->Comp->find('first', array(
    'conditions' => array('Comp.id' => $id),
    'contain' => array(
        'Comp.id' => array(
            'fields' => array('Comp.id'),
        ),
        'Slot' => array(
            'fields' => array(
                'Slot.start_time',
                'Slot.end_time'
            )
        ),
        'Team'
    )
));

... aber bei der Ausführung einer Warnung wird angezeigt:

Warnung (512): Modell "Comp" ist nicht im Zusammenhang mit model „Comp“ [CORE / Kuchen / libs / Modell / Verhaltensweisen / containable.php, Linie 363]

Der Beginn meines Comp Modell ist wie folgt:

var $name = 'Comp';
var $hasMany = array('Team', 'Round', 'Match');
var $belongsTo = array('Generation');
var $hasAndBelongsToMany = array('Slot');
var $actsAs = array('Containable');

Ich bin mit CakePHP 1.3.6

Alle Ideen, was diese verursachen kann?

War es hilfreich?

Lösung

$comp = $this->Comp->find('first', array(
    'conditions' => array('Comp.id' => $id),
    'fields'     => array('Comp.id'),
    'contain'    => array(
        'Slot'       => array(
            'fields'     => array(
                'Slot.start_time',
                'Slot.end_time'
            )
        ),
        'Team'
    )
));

You told it to contain the related Comp.id, which means the model Comp related to Comp, which doesn't exist. You probably meant to simply set the fields option of the Comp model itself?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top