【问题标题】:Cake Relations with diffent name不同名称的蛋糕关系
【发布时间】:2012-07-23 09:15:26
【问题描述】:

我有一个表用户和一个表组。每个组都有一个 GroupLeader。 所以我使用的字段是 groupLeader ($hasOne),其中包含用户的外键。

我无法获得这种关系。所以我的问题是,如何在具有不同名称的字段上定义关系。

感谢您的提示。 远方

【问题讨论】:

    标签: cakephp relational-database relationship


    【解决方案1】:

    你的模特应该看起来:

    class Group extends AppModel
    {
        public $name = 'Group';
        public $belongsTo = array('GroupLeader' => array(
                                                       'className' => 'User',
                                                       'foreignKey' => 'groupLeader'
                                                        )
                                 );
    }
    

    试试上面的代码。并询问它是否不适合您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      相关资源
      最近更新 更多