テーブルは以下のような感じです。
users
-users_id (primary+auto incluse)
-login_date (date_time) ログイン時にcurrent dateがupdateされる
-itemA_state (int)アイテムAテーブルの状態(未購入,購入中など)
-itemB_state (int)
-state(int) ユーザーの状態(0=登録済み、1=禁止状態など)
order
-order_id (primary+auto incluse)
-users_id (int)
-item_id (int)
-payment_date (datetime) 購入日時
-expire_date (datetime) 有効期限
itemA
-item_id (primary+auto incluse)
-item_type (int) 契約種類
-users_id (int)
-state (int) 0=使用中、1=期限切れ
itemB(アイテムB)
itemAとほぼ同じ
ユーザーがアイテムを購入したらpayment_dateとexpire_date(+10days等)を挿入するようにしています。
orderのexpire_dateがusersのlogin_dateを越えると、itemAかBテーブルのstateを1に、また同時にユーザーテーブルのitemAかB stateを1にさせたいのですが、
どうすればよいでしょうか。
(http://q.hatena.ne.jp/1206163832こちらでも質問させて頂きました。)
時間がないので、サンプルソースを頂けると幸いです。
宜しく御願い致します。
またこのテーブルにはこのフィールドは必要ないんじゃないか、というご意見/ご指摘もあれば宜しく御願い致します。
コメント(0件)