当我遇到这种情况时,我遇到了一个问题:
我必须记录用户所做的事情,当然用户可以做很多不同的操作。
我认为有两种不同的方法来实现它我只需要有人可以帮助我遵循正确的方法。
第一种方式:
创建 2 个不同的表
- 历史用户
- 历史类型
History_user表
id | user_id | history_type (int)
1 1 1
1 3 2
历史类型
id | name_action (string)
1 The user has posted on the wall
2 The user has change his profile picture
然后只需加入查询History_user.history_type = History_type.id
第二种方式:
是创建 History_user 表和一个名为 Converter 的帮助程序示例。
<?php
class Converter {
function history($type_history) {
switch($type_history) {
case 1:
$human_history = "The user has posted on the wall";
break;
case 2:
$human_history = "The user has change his profile picture";
break;
}
return $human_history;
}
}
$converter = new Converter();
$converter->history(1);
在性能和可维护性方面,我一直在寻找更好的方法。谢谢你。