理由だけというテーブル内のすべての通知を表示しません「通知」
以下のための通知である210
id | user_id | from_user_id | notification
- ID =通知ID
- のuser_id =?
- from_user_id =誰が通知を送信しましたか?
- 通知=メッセージ擬似コードとして次に
:
// Create a notification from User A to User B
$this->db->insert ('notifications', array ('user_id' => $friends_id, 'from_user_id' => $current_user_id, 'notification' => $message));
// The meanwhile, on your home page or somewhere, wherever you want to display notifications
$this->db->where ('user_id', $current_user_id)
$notifications = $this->db->get ('user_id');
foreach ($notifications as $notification)
{
// Display the notification as needed
// Optionally delete the notification as it is displayed if it is a "one off" alert only
}
基本的に、お気に入りの友人に通知することを選択した場合、私は最初に現在のユーザーのお気に入りのユーザーIDを取得するクエリを実行し、それらのIDごとに通知テーブルに一括挿入しますか?それは十分に論理的だと思われる。このようなものはもともと私の心を横切っていましたが、おそらく別の方法があると思いました。これは論理的なやり方のようです。 –
@Dwayne、ええ。または、サブクエリ(http://dev.mysql.com/doc/refman/5.5/en/subqueries.html)を実行することもできます。いずれにせよ、これはこれを行うための最も論理的でクリーンな方法のようです。すべてを最適化するために7-14日以上経過した通知をすべて削除しますが、それはあなた次第です。 – Shoe
シンプルで信頼性の高い方法+1 –