doulao7572 2017-05-10 03:44 采纳率: 0%
浏览 43
已采纳

将活动记录到数据库yii框架

I'm using yii framework and I want to make an activity logging for every action that user do in my web. All of their activity will be saved to a table in database.

The things that will be recorded are:

  • user ID
  • table name (inserted, deleted, edited item)
  • time_action
  • activity (what did they do. ex: created project_name)

Please help. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dousi6701 2017-05-10 05:28
    关注

    I'm not sure what you are trying to do but is it like when a user deletes some item; then entry should be logged in database for that user? If yes, then you can create a common class and a static method in it like,

    yourCommonClass::setActivityLog(user_id,activity_msg,time);
    

    and put this code in every action that you have written. ex. actionUpdate, actionDelete.

    • you can get the user_id from Yii::app()->user->id
    • put you custom activity message like "User #user_id created new item" etc.
    • time you can get it while saving into database.

    By the way, create a table and model for the same like ActivityLog. ;) This is what I did in my project.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度