1
|
|
|
<?php |
2
|
|
|
namespace AOE\Crawler\Domain\Repository; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2016 AOE GmbH <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use TYPO3\CMS\Core\Database\Query\QueryBuilder; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class AbstractRepository |
33
|
|
|
* |
34
|
|
|
* @package AOE\Crawler\Domain\Repository |
35
|
|
|
*/ |
36
|
|
|
abstract class AbstractRepository |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string table name |
41
|
|
|
*/ |
42
|
|
|
protected $tableName; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var QueryBuilder |
46
|
|
|
*/ |
47
|
|
|
protected $queryBuilder = QueryBuilder::class; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Counts all in repository |
51
|
|
|
* |
52
|
|
|
* @return integer |
53
|
|
|
*/ |
54
|
10 |
|
public function countAll() |
55
|
|
|
{ |
56
|
10 |
|
$count = $this->queryBuilder |
57
|
10 |
|
->count('*') |
58
|
10 |
|
->from($this->tableName) |
59
|
10 |
|
->execute() |
60
|
10 |
|
->fetchColumn(0); |
61
|
|
|
|
62
|
10 |
|
return $count; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $processId |
67
|
|
|
* |
68
|
|
|
* @return bool|string |
69
|
|
|
*/ |
70
|
1 |
|
public function countAllByProcessId($processId) |
71
|
|
|
{ |
72
|
1 |
|
$count = $this->queryBuilder |
73
|
1 |
|
->count('*') |
74
|
1 |
|
->from($this->tableName) |
75
|
1 |
|
->where( |
76
|
1 |
|
$this->queryBuilder->expr()->eq('process_id', $this->queryBuilder->createNamedParameter($processId)) |
77
|
|
|
) |
78
|
1 |
|
->execute() |
79
|
1 |
|
->fetchColumn(0); |
80
|
|
|
|
81
|
1 |
|
return $count; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|