1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 04:01:31 +08:00
2022-09-19 17:58:52 +08:00

34 lines
758 B
PHP

<?php
/**
* @copyright Copyright (c) 2022 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
trait PageTrait
{
protected function insertPages(array $rows)
{
foreach ($rows as $key => $row) {
$exists = $this->pageExits($row['alias']);
if ($exists) unset($rows[$key]);
}
if (count($rows) == 0) return;
$this->table('kg_page')->insert($rows)->save();
}
protected function pageExits($alias)
{
$row = $this->getQueryBuilder()
->select('*')
->from('kg_page')
->where(['alias' => $alias])
->execute()->fetch();
return $row ? true : false;
}
}