Keywords.php 613 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021 勾股工作室
  4. * @license https://opensource.org/licenses/Apache-2.0
  5. * @link https://www.gougucms.com
  6. */
  7. namespace app\admin\model;
  8. use think\Model;
  9. // 关键字模型
  10. class Keywords extends Model
  11. {
  12. // 关联关键字
  13. public function increase($keywords)
  14. {
  15. $is_exist = $this->where('title', $keywords)->find();
  16. if ($is_exist) {
  17. $res = $is_exist['id'];
  18. } else {
  19. $res = $this->strict(false)->field(true)->insertGetId(['title' => $keywords, 'create_time' => time()]);
  20. }
  21. return $res;
  22. }
  23. }