-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTag.php
57 lines (46 loc) · 1.37 KB
/
Tag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace IntegerNet\AsyncVarnish\Model\ResourceModel;
class Tag extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* DB Storage table name
*/
const TABLE_NAME = 'integernet_async_varnish_tags';
/* must be protected */
protected function _construct() //phpcs:ignore MEQP2.PHP.ProtectedClassMember.FoundProtected
{
$this->_init(self::TABLE_NAME, 'entity_id');
}
public function getMaxTagId(int $limit):array
{
$connection = $this->getConnection();
$subSetSelect = $connection->select()->from(
$this->getTable(self::TABLE_NAME),
['entity_id','tag']
)->order(
'entity_id ASC'
)->limit(
$limit
);
$maxIdSelect = $connection->select()->from(
$subSetSelect,
['max_id'=>'MAX(entity_id)']
);
return $connection->fetchRow($maxIdSelect);
}
public function getUniqueTagsByMaxId(int $maxId):array
{
$connection = $this->getConnection();
$select = $connection->select()->from(
['main_table' => $this->getTable(self::TABLE_NAME)],
['tag']
)->group(
'tag'
)->where(
'main_table.entity_id <= ?',
$maxId
);
return $connection->fetchAll($select);
}
}