HATBM关系错误

时间:2013-05-01 15:57:33

标签: cakephp

我在cakephp中遇到HABTM关系问题。我有2个模型Campaign和Person我创建了3个数据库表活动,人员和campaign_persons 模型看起来像这样:

广告系列

class Campaign extends AppModel {

    var $name = 'Campaign';
    var $displayField = 'nombre';
    var $belongsTo = array(
        'Client' => array(
            'className' => 'Client',
            'foreignKey' => 'client_id'
        ),
        'Template' => array(
            'className' => 'Template',
            'foreignKey' => 'template_id'
        )
    );
    var $hasAndBelongsToMany = array(
        'Persona' =>
        array('className' => 'Person',
            'joinTable' => 'campaigns_persons',
            'foreignKey' => 'campaign_id',
            'associationForeignKey' => 'person_id',
            'with' => '',
            'conditions' => '',
            'order' => '',
            'limit' => '',
            'unique' => true,
            'finderQuery' => '',
            'deleteQuery' => '',
            'insertQuery' => ''
        )
    );
}

class Person extends AppModel {

    var $name = 'Person';
    var $displayField = 'name';
    var $belongsTo = array(
        'Client' => array(
            'className' => 'Client',
            'foreignKey' => 'client_id',
        ),
    );
}

控制器如下所示:

        $this->Campaign->create();
    if ($this->Campaign->save($this->data)) {
        $this->Session->write('campaign_id', $this->Campaign->id);
        $this->Session->setFlash(__("Listado de clientes agregado", true));
        return true;
    }//fin saveAll

它抛出了这个错误:

    Fatal error: Cannot access empty property in
    1   0.0012  372600  {main}( )   ..\index.php:0
    2   0.1148  4012344 Dispatcher->dispatch( ) ..\index.php:86
    3   0.1319  4967600 Dispatcher->_invoke( )  ..\dispatcher.php:171
    4   2.2085  9815800 call_user_func_array ( )    ..\dispatcher.php:204
    5   2.2085  9815968 CampaignsController->end_campaign( )    ..\dispatcher.php:204
    6   2.4742  9845328 CampaignsController->__saveAll( )   ..\campaigns_controller.php:221
    7   2.4743  9845568 Model->save( )  ..\campaigns_controller.php:281

我不知道发生了什么。

0 个答案:

没有答案