在_构造函数-CAKEPHP中绑定关系时,依赖项不起作用

在_构造函数-CAKEPHP中绑定关系时,依赖项不起作用,cakephp,Cakephp,实际上,在我的场景中,我是模型构造函数中的绑定关系。实际上,我需要在我的模型关系中使用一个模型属性,而Cakephp阻止在默认关系中使用模型属性。所以我不能用 public $hasMany = array( 'ProductDetail' => array( 'className' => 'ProductDetail', 'conditions' => array( 'Produc

实际上,在我的场景中,我是模型构造函数中的绑定关系。实际上,我需要在我的模型关系中使用一个模型属性,而Cakephp阻止在默认关系中使用模型属性。所以我不能用

public $hasMany = array(
        'ProductDetail' => array(
            'className' => 'ProductDetail',
            'conditions' => array(
                'ProductDetail.language_id' => $this->languageId //Throws error
            ),
            'dependent' => true
        ),
    );
所以我开了个玩笑。我确实在模型的
\uu construct()
函数上绑定了模型关系。下面是我的代码

public function __construct($id = false, $table = null, $ds = null) {
        parent::__construct($id, $table, $ds);
        $this->bindModel(array(
            "hasMany" => array(
                'ProductDetail' => array(
                    'className' => 'ProductDetail',
                    'dependent' => true,
                    'conditions' => array(
                        'ProductDetail.language_id' => $this->languageId //Doesn't throw an error
                    )
                )
            )
                )
        );
    }

在每个场景中,这个技巧对我都有效。但是当我删除产品时,当我在
\uu construct()
函数下绑定关系时,依赖模型不能被删除。有没有办法让这个技巧奏效,或者我需要手动触发依赖功能

经过研究,我发现在
bindModel
函数中将第二个参数传递给
false
。因为这将使您的动态绑定持续请求的时间。所以在这种情况下,
Model::bindModel
函数如下所示

$this->bindModel(array(
            "hasMany" => array(
                'ProductDetail' => array(
                    'className' => 'ProductDetail',
                    'dependent' => true,
                    'conditions' => array(
                        'ProductDetail.language_id' => $this->languageId
                    )
                )
            )
                ), false
        );