12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\user\model;
- use think\Model;
- class UserComment extends Model{
- protected $createTime = "inputtime";
- protected $updateTime = '';
- protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
-
- public function initialize(){
- parent::initialize();
- }
-
- public function getInfo($user, $type, $page = 0){
- return $this->db()
- ->alias("c")
- ->field("c.comment_id s, c.inputtime t, c.content c, u.nickname n")
- ->join("gd_user u", "u.id = c.comment_id", "LEFT")
- ->where(['c.user_id'=>$user, "c.type"=>$type])
- ->page($page, config('paginate.list_rows'))
- ->order("inputtime DESC")
- ->select();
- }
-
- public function getInfoByComment($user, $comment, $type, $page = 0){
- return $this->db()
- ->alias("c")
- ->field("c.comment_id s, c.inputtime t, c.user_id u,c.content c, u.nickname n")
- ->join("gd_user u", "u.id = c.comment_id", "LEFT")
- ->where(['c.user_id'=>[['eq', $user], ['eq', $comment], 'or']])
- ->where(['c.comment_id'=>[['eq', $user], ['eq', $comment], 'or']])
- ->where(["c.type"=>$type])
- ->page($page, config('paginate.list_rows'))
- ->order("inputtime DESC")
- ->select();
- }
-
- public function add($data){
- return $this->save($data);
- }
-
- }
|