cakephp(2.7.8)
PHP 5.6
社員モデル(Employee)
に、技能モデル、免許モデルをアソシエーションしたいのですが、
以下のように宣言するとエラーになります。
php
1 2<?php 3 4App::uses('AppModel', 'Model'); 5 6class Employee extends AppModel { 7 8 9 //技能 10 public $belongsTo = array( 11 'Skill'=>array( 12 'className' => 'Skill', 13 'foreignKey' => 'id', 14 15 ) 16 ); 17 18 //免許 19 public $belongsTo = array( 20 'License'=>array( 21 'className' => 'License', 22 'foreignKey' => 'id', 23 ) 24 ); 25 26 27 28} 29
エラーメッセージ
「Fatal Error
Error: Cannot redeclare Employee::$belongsTo
」
すでに
public $belongsTo
を宣言済みだからと思います。
一度の
public $belongsTo
で複数のモデルと結合を宣言したい場合、
どのように記述するのでしょうか?
宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。