UserComment.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 getInfoByComment($user, $comment, $type, $page = 0){
  22. return $this->db()
  23. ->alias("c")
  24. ->field("c.comment_id s, c.inputtime t, c.content c, u.nickname n")
  25. ->join("gd_user u", "u.id = c.comment_id", "LEFT")
  26. ->where(['c.user_id'=>$user, "c.comment_id"=>$comment, "c.type"=>$type])
  27. ->page($page, config('paginate.list_rows'))
  28. ->order("inputtime DESC")
  29. ->select();
  30. }
  31. public function add($data){
  32. return $this->save($data);
  33. }
  34. }