はじめまして!
現在CakePHPのリレーションシップ(hasOne)を活用して、
ProfileモデルをUserモデルに連携している者です。
lang
1//ProfilesController.php 2 public function index() { 3 4 $user = AuthComponent::user('id'); 5 $this->Profile->user_id = $user; 6 $this->set('profile', $this->Profile->read()); 7 }
ユーザーのプロフィールを閲覧させるために上記のコードを書いたのですが、以下のようなエラーが出てしまいます。
Notice (8): Indirect modification of overloaded property ProfilesController::$Profile has no effect
Warning (2): Creating default object from empty value
$this->Profile->user_id = $user;
Error: Call to a member function read() on a non-object
このような場合、どのような処置を取ればよいでしょうか?
是非ご教授のほどよろしくお願い申し上げます。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。