私は人々がソーシャルウェブサイトのように他の人々と会うプロジェクトに取り組んでいます。次のように機能します。1人がFacebookのようにイベントを作成し、イベントがいつ発生するか、イベントの最大スポット数などを書き込み、人々がそれらに参加します。
データベースにmet_with
変数があり、ユーザーのプロファイルに表示されます。これは、たとえば、誰かが30スポットのイベントを作成した場合、人々はイベントに参加しますが、おそらく15人または25人だけが参加し、ユーザーがそのイベントに参加するとき、彼は人々と会いfullfilled spots - 1
ます。
しかし、私が直面している問題は、met_with
ユーザーが参加した後ではなく、イベントが発生した後に変数を設定したいということです。私はそのmet_with
変数をに等しくしましmaximum spot - 1
たが、私が言ったように、そのイベントが最大値を満たすことは保証されていませんスポット。
met_with
メンバーの変数を毎日更新するためにファイルを実行したくないのですが、met with
イベントが発生した後にのみ変数を設定する関数を作成することは可能ですか。
これが私がしたことです:
// above of here, i query the db for the event, i make the $free_spots = $free_spots - 1 after user clicks attending, fetching and defining $max_spot, $free_spots exc.
$met_with = $met_with + $max_spot - 1;
try{
$update_member_query = "UPDATE `members` SET `met_with`=:met_with, `attended` = `attended` +1 WHERE `id`=:userid";
$update_member_query_do = $db->prepare($update_member_query);
$update_member_query_do->bindParam(':userid', $userid, PDO::PARAM_INT);
$update_member_query_do->bindParam(':met_with', $met_with, PDO::PARAM_INT);
$update_member_query_do->execute() or die(print_r($update_member_query_do->errorInfo(), true));
}
catch(PDOException $e) {
$log->logError($e." - ".basename(__FILE__));
}