はじめまして!
現在CakePHPを活用してTwitterのタイムライン機能を実装しようと考えております。
データベースには以下のようなfollowsテーブル、timelinesテーブルの2つを構築しています。
(followsテーブル)
id 主キー
from_id (フォローする)ユーザーID
to_id (フォローされる)ユーザーID
from_idのユーザーが、to_idのユーザーをフォローする形式
(timelinesテーブル)
id 主キー
comment コメント
whom ユーザーID
このとき、自分はもちろん自分がフォローしているユーザーのコメントをfind(all)で取得したいのですが、どのようなコードを記述すればよいかわかりません。
PHP
1//TimelinesController.php 2 public function index() { 3 4 $id= AuthComponent::user('id'); //自らのユーザーID 5 6 $conditions = array( 7 array( 'or' => array('Timeline.whom' => $id)), 8 array( 'or' => array('Timeline.whom' => ???)), //フォローしているユーザーIDをどう取得すればよいかわからない 9); 10 11 $this->set('timelines', $this->Timeline->find('all', array( 12 'conditions' => $conditions, 13 'order' => array('Timeline.id' => 'desc') 14))); 15 16 } 17
少しでも何かお分かりの方は、是非ともご教授ください!!
よろしくお願い申し上げます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。