LogApiModel.php 472 B

12345678910111213141516171819202122
  1. <?php
  2. namespace app\index\model;
  3. use think\Model;
  4. use think\Db;
  5. class LogApiModel extends Model
  6. {
  7. public function __construct()
  8. {
  9. $date = date('Ymd',time());
  10. $this->table = 'log_api'.'_'.$date;
  11. $exist = Db::query('show tables like "'.$this->table.'"');
  12. if(empty($exist)){
  13. $sql = "CREATE TABLE IF NOT EXISTS {$this->table} LIKE log_api";
  14. Db::execute($sql);
  15. }
  16. parent::__construct();
  17. }
  18. }