ViewUnique.php 455 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace app\common\model;
  3. use think\db\Query;
  4. use think\Model;
  5. /**
  6. */
  7. class ViewUnique extends Model
  8. {
  9. protected $pk='date';
  10. public static function add(){
  11. $date=strtotime(date('Y-m-d 00:00:00'));
  12. $has=self::where('date',$date)->find();
  13. if($has){
  14. $has->setInc('num');
  15. }else{
  16. self::create([
  17. 'date'=>$date,
  18. 'num'=>1,
  19. ]);
  20. }
  21. }
  22. }