UserComment.php 741 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\user\model;
  3. use think\Model;
  4. class UserComment extends Model{
  5. protected $createTime = "inputtime";
  6. protected $updateTime = '';
  7. protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
  8. public function initialize(){
  9. parent::initialize();
  10. }
  11. public function getInfo($user, $type, $page = 0){
  12. return $this->db()
  13. ->alias("c")
  14. ->field("c.comment_id s, c.inputtime t, c.content c, u.nickname n")
  15. ->join("gd_user u", "u.id = c.comment_id", "LEFT")
  16. ->where(['c.user_id'=>$user, "c.type"=>$type])
  17. ->page($page, config('paginate.list_rows'))
  18. ->order("inputtime DESC")
  19. ->select();
  20. }
  21. public function add($data){
  22. return $this->save($data);
  23. }
  24. }