Completed
Push — development ( 227e3a...98bb7e )
by Andrij
14:37
created

PageLinkProductsQuery   D

Complexity

Total Complexity 72

Size/Duplication

Total Lines 432
Duplicated Lines 100 %

Coupling/Cohesion

Components 3
Dependencies 13

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 432
loc 432
rs 4.7474
wmc 72
lcom 3
cbo 13

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A create() 15 15 4
C findPk() 21 21 21
C findPkSimple() 23 23 9
A findPkComplex() 10 10 2
A findPks() 13 13 3
A filterByPrimaryKey() 7 7 1
A filterByPrimaryKeys() 14 14 3
B filterByLinkId() 22 22 6
B filterByProductId() 22 22 6
A filterByPageLink() 16 16 4
B joinPageLink() 23 23 4
A usePageLinkQuery() 6 6 2
A prune() 10 10 2
A doDeleteAll() 20 20 2
B delete() 24 24 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like PageLinkProductsQuery often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use PageLinkProductsQuery, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace mod_link\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use Propel\Runtime\Propel;
8
use Propel\Runtime\ActiveQuery\Criteria;
9
use Propel\Runtime\ActiveQuery\ModelCriteria;
10
use Propel\Runtime\ActiveQuery\ModelJoin;
11
use Propel\Runtime\Collection\ObjectCollection;
12
use Propel\Runtime\Connection\ConnectionInterface;
13
use Propel\Runtime\Exception\PropelException;
14
use mod_link\models\PageLinkProducts as ChildPageLinkProducts;
15
use mod_link\models\PageLinkProductsQuery as ChildPageLinkProductsQuery;
16
use mod_link\models\Map\PageLinkProductsTableMap;
17
18
/**
19
 * Base class that represents a query for the 'page_link_products' table.
20
 *
21
 *
22
 *
23
 * @method     ChildPageLinkProductsQuery orderByLinkId($order = Criteria::ASC) Order by the link_id column
24
 * @method     ChildPageLinkProductsQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
25
 *
26
 * @method     ChildPageLinkProductsQuery groupByLinkId() Group by the link_id column
27
 * @method     ChildPageLinkProductsQuery groupByProductId() Group by the product_id column
28
 *
29
 * @method     ChildPageLinkProductsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
30
 * @method     ChildPageLinkProductsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
31
 * @method     ChildPageLinkProductsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
32
 *
33
 * @method     ChildPageLinkProductsQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
34
 * @method     ChildPageLinkProductsQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
35
 * @method     ChildPageLinkProductsQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
36
 *
37
 * @method     ChildPageLinkProductsQuery leftJoinPageLink($relationAlias = null) Adds a LEFT JOIN clause to the query using the PageLink relation
38
 * @method     ChildPageLinkProductsQuery rightJoinPageLink($relationAlias = null) Adds a RIGHT JOIN clause to the query using the PageLink relation
39
 * @method     ChildPageLinkProductsQuery innerJoinPageLink($relationAlias = null) Adds a INNER JOIN clause to the query using the PageLink relation
40
 *
41
 * @method     ChildPageLinkProductsQuery joinWithPageLink($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the PageLink relation
42
 *
43
 * @method     ChildPageLinkProductsQuery leftJoinWithPageLink() Adds a LEFT JOIN clause and with to the query using the PageLink relation
44
 * @method     ChildPageLinkProductsQuery rightJoinWithPageLink() Adds a RIGHT JOIN clause and with to the query using the PageLink relation
45
 * @method     ChildPageLinkProductsQuery innerJoinWithPageLink() Adds a INNER JOIN clause and with to the query using the PageLink relation
46
 *
47
 * @method     \mod_link\models\PageLinkQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
48
 *
49
 * @method     ChildPageLinkProducts findOne(ConnectionInterface $con = null) Return the first ChildPageLinkProducts matching the query
50
 * @method     ChildPageLinkProducts findOneOrCreate(ConnectionInterface $con = null) Return the first ChildPageLinkProducts matching the query, or a new ChildPageLinkProducts object populated from the query conditions when no match is found
51
 *
52
 * @method     ChildPageLinkProducts findOneByLinkId(int $link_id) Return the first ChildPageLinkProducts filtered by the link_id column
53
 * @method     ChildPageLinkProducts findOneByProductId(int $product_id) Return the first ChildPageLinkProducts filtered by the product_id column *
54
55
 * @method     ChildPageLinkProducts requirePk($key, ConnectionInterface $con = null) Return the ChildPageLinkProducts by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
56
 * @method     ChildPageLinkProducts requireOne(ConnectionInterface $con = null) Return the first ChildPageLinkProducts matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
57
 *
58
 * @method     ChildPageLinkProducts requireOneByLinkId(int $link_id) Return the first ChildPageLinkProducts filtered by the link_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
59
 * @method     ChildPageLinkProducts requireOneByProductId(int $product_id) Return the first ChildPageLinkProducts filtered by the product_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
60
 *
61
 * @method     ChildPageLinkProducts[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildPageLinkProducts objects based on current ModelCriteria
62
 * @method     ChildPageLinkProducts[]|ObjectCollection findByLinkId(int $link_id) Return ChildPageLinkProducts objects filtered by the link_id column
63
 * @method     ChildPageLinkProducts[]|ObjectCollection findByProductId(int $product_id) Return ChildPageLinkProducts objects filtered by the product_id column
64
 * @method     ChildPageLinkProducts[]|\Propel\Runtime\Util\PropelModelPager paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null) Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit
65
 *
66
 */
0 ignored issues
show
introduced by
Additional blank lines found at end of doc comment
Loading history...
67 View Code Duplication
abstract class PageLinkProductsQuery extends ModelCriteria
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
69
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
70
71
    /**
72
     * Initializes internal state of \mod_link\models\Base\PageLinkProductsQuery object.
73
     *
74
     * @param     string $dbName The database name
75
     * @param     string $modelName The phpName of a model, e.g. 'Book'
76
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
77
     */
78
    public function __construct($dbName = 'Shop', $modelName = '\\mod_link\\models\\PageLinkProducts', $modelAlias = null)
79
    {
80
        parent::__construct($dbName, $modelName, $modelAlias);
81
    }
82
83
    /**
84
     * Returns a new ChildPageLinkProductsQuery object.
85
     *
86
     * @param     string $modelAlias The alias of a model in the query
87
     * @param     Criteria $criteria Optional Criteria to build the query from
88
     *
89
     * @return ChildPageLinkProductsQuery
90
     */
91
    public static function create($modelAlias = null, Criteria $criteria = null)
92
    {
93
        if ($criteria instanceof ChildPageLinkProductsQuery) {
0 ignored issues
show
Bug introduced by
The class mod_link\models\PageLinkProductsQuery does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
94
            return $criteria;
95
        }
96
        $query = new ChildPageLinkProductsQuery();
97
        if (null !== $modelAlias) {
98
            $query->setModelAlias($modelAlias);
99
        }
100
        if ($criteria instanceof Criteria) {
101
            $query->mergeWith($criteria);
102
        }
103
104
        return $query;
105
    }
106
107
    /**
108
     * Find object by primary key.
109
     * Propel uses the instance pool to skip the database if the object exists.
110
     * Go fast if the query is untouched.
111
     *
112
     * <code>
0 ignored issues
show
introduced by
Doc comment long description must start with a capital letter
Loading history...
113
     * $obj = $c->findPk(array(12, 34), $con);
114
     * </code>
115
     *
116
     * @param array[$link_id, $product_id] $key Primary key to use for the query
0 ignored issues
show
Documentation introduced by
The doc-type array[$link_id, could not be parsed: Expected "]" at position 2, but found "$link_id". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
Bug introduced by
There is no parameter named $product_id]. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
introduced by
Expected 1 spaces after parameter type; 0 found
Loading history...
introduced by
Doc comment for parameter $link_id, does not match actual variable name $con
Loading history...
117
     * @param ConnectionInterface $con an optional connection object
118
     *
119
     * @return ChildPageLinkProducts|array|mixed the result, formatted by the current formatter
120
     */
121
    public function findPk($key, ConnectionInterface $con = null)
122
    {
123
        if ($key === null) {
124
            return null;
125
        }
126
        if ((null !== ($obj = PageLinkProductsTableMap::getInstanceFromPool(serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])])))) && !$this->formatter) {
127
            // the object is already in the instance pool
128
            return $obj;
129
        }
130
        if ($con === null) {
131
            $con = Propel::getServiceContainer()->getReadConnection(PageLinkProductsTableMap::DATABASE_NAME);
132
        }
133
        $this->basePreSelect($con);
134
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
135
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
0 ignored issues
show
Coding Style introduced by
Multi-line IF statement not indented correctly; expected 12 spaces but found 9
Loading history...
136
         || $this->map || $this->having || $this->joins) {
0 ignored issues
show
Coding Style introduced by
Multi-line IF statement not indented correctly; expected 12 spaces but found 9
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
137
            return $this->findPkComplex($key, $con);
138
        } else {
139
            return $this->findPkSimple($key, $con);
140
        }
141
    }
142
143
    /**
144
     * Find object by primary key using raw SQL to go fast.
145
     * Bypass doSelect() and the object formatter by using generated code.
146
     *
147
     * @param     mixed $key Primary key to use for the query
148
     * @param     ConnectionInterface $con A connection object
149
     *
150
     * @throws \Propel\Runtime\Exception\PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
151
     *
152
     * @return ChildPageLinkProducts A model object, or null if the key is not found
0 ignored issues
show
Documentation introduced by
Should the return type not be ChildPageLinkProducts|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
153
     */
154
    protected function findPkSimple($key, ConnectionInterface $con)
155
    {
156
        $sql = 'SELECT link_id, product_id FROM page_link_products WHERE link_id = :p0 AND product_id = :p1';
157
        try {
158
            $stmt = $con->prepare($sql);
159
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
160
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
161
            $stmt->execute();
162
        } catch (Exception $e) {
163
            Propel::log($e->getMessage(), Propel::LOG_ERR);
164
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
165
        }
166
        $obj = null;
167
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
168
            /** @var ChildPageLinkProducts $obj */
169
            $obj = new ChildPageLinkProducts();
170
            $obj->hydrate($row);
171
            PageLinkProductsTableMap::addInstanceToPool($obj, serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])]));
172
        }
173
        $stmt->closeCursor();
174
175
        return $obj;
176
    }
177
178
    /**
179
     * Find object by primary key.
180
     *
181
     * @param     mixed $key Primary key to use for the query
182
     * @param     ConnectionInterface $con A connection object
183
     *
184
     * @return ChildPageLinkProducts|array|mixed the result, formatted by the current formatter
185
     */
186
    protected function findPkComplex($key, ConnectionInterface $con)
187
    {
188
        // As the query uses a PK condition, no limit(1) is necessary.
189
        $criteria = $this->isKeepQuery() ? clone $this : $this;
190
        $dataFetcher = $criteria
191
            ->filterByPrimaryKey($key)
192
            ->doSelect($con);
193
194
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
195
    }
196
197
    /**
198
     * Find objects by primary key
199
     * <code>
200
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
201
     * </code>
202
     * @param     array $keys Primary keys to use for the query
203
     * @param     ConnectionInterface $con an optional connection object
204
     *
205
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
206
     */
207
    public function findPks($keys, ConnectionInterface $con = null)
208
    {
209
        if (null === $con) {
210
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
211
        }
212
        $this->basePreSelect($con);
213
        $criteria = $this->isKeepQuery() ? clone $this : $this;
214
        $dataFetcher = $criteria
215
            ->filterByPrimaryKeys($keys)
216
            ->doSelect($con);
217
218
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
219
    }
220
221
    /**
222
     * Filter the query by primary key
223
     *
224
     * @param     mixed $key Primary key to use for the query
225
     *
226
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use PageLinkProductsQuery.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
227
     */
228
    public function filterByPrimaryKey($key)
229
    {
230
        $this->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $key[0], Criteria::EQUAL);
231
        $this->addUsingAlias(PageLinkProductsTableMap::COL_PRODUCT_ID, $key[1], Criteria::EQUAL);
232
233
        return $this;
234
    }
235
236
    /**
237
     * Filter the query by a list of primary keys
238
     *
239
     * @param     array $keys The list of primary key to use for the query
240
     *
241
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Should the return type not be Criteria?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
242
     */
243
    public function filterByPrimaryKeys($keys)
244
    {
245
        if (empty($keys)) {
246
            return $this->add(null, '1<>1', Criteria::CUSTOM);
247
        }
248
        foreach ($keys as $key) {
249
            $cton0 = $this->getNewCriterion(PageLinkProductsTableMap::COL_LINK_ID, $key[0], Criteria::EQUAL);
250
            $cton1 = $this->getNewCriterion(PageLinkProductsTableMap::COL_PRODUCT_ID, $key[1], Criteria::EQUAL);
251
            $cton0->addAnd($cton1);
252
            $this->addOr($cton0);
253
        }
254
255
        return $this;
256
    }
257
258
    /**
259
     * Filter the query on the link_id column
260
     *
261
     * Example usage:
262
     * <code>
263
     * $query->filterByLinkId(1234); // WHERE link_id = 1234
264
     * $query->filterByLinkId(array(12, 34)); // WHERE link_id IN (12, 34)
265
     * $query->filterByLinkId(array('min' => 12)); // WHERE link_id > 12
266
     * </code>
267
     *
268
     * @see       filterByPageLink()
269
     *
270
     * @param     mixed $linkId The value to use as filter.
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
271
     *              Use scalar values for equality.
272
     *              Use array values for in_array() equivalent.
273
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
274
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
275
     *
276
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Should the return type not be ModelCriteria?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
277
     */
278
    public function filterByLinkId($linkId = null, $comparison = null)
279
    {
280
        if (is_array($linkId)) {
281
            $useMinMax = false;
282
            if (isset($linkId['min'])) {
283
                $this->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $linkId['min'], Criteria::GREATER_EQUAL);
284
                $useMinMax = true;
285
            }
286
            if (isset($linkId['max'])) {
287
                $this->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $linkId['max'], Criteria::LESS_EQUAL);
288
                $useMinMax = true;
289
            }
290
            if ($useMinMax) {
291
                return $this;
292
            }
293
            if (null === $comparison) {
294
                $comparison = Criteria::IN;
295
            }
296
        }
297
298
        return $this->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $linkId, $comparison);
299
    }
300
301
    /**
302
     * Filter the query on the product_id column
303
     *
304
     * Example usage:
305
     * <code>
306
     * $query->filterByProductId(1234); // WHERE product_id = 1234
307
     * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
308
     * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
309
     * </code>
310
     *
311
     * @param     mixed $productId The value to use as filter.
312
     *              Use scalar values for equality.
313
     *              Use array values for in_array() equivalent.
314
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
315
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
316
     *
317
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Should the return type not be ModelCriteria?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
318
     */
319
    public function filterByProductId($productId = null, $comparison = null)
320
    {
321
        if (is_array($productId)) {
322
            $useMinMax = false;
323
            if (isset($productId['min'])) {
324
                $this->addUsingAlias(PageLinkProductsTableMap::COL_PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
325
                $useMinMax = true;
326
            }
327
            if (isset($productId['max'])) {
328
                $this->addUsingAlias(PageLinkProductsTableMap::COL_PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
329
                $useMinMax = true;
330
            }
331
            if ($useMinMax) {
332
                return $this;
333
            }
334
            if (null === $comparison) {
335
                $comparison = Criteria::IN;
336
            }
337
        }
338
339
        return $this->addUsingAlias(PageLinkProductsTableMap::COL_PRODUCT_ID, $productId, $comparison);
340
    }
341
342
    /**
343
     * Filter the query by a related \mod_link\models\PageLink object
344
     *
345
     * @param \mod_link\models\PageLink|ObjectCollection $pageLink The related object(s) to use as filter
346
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
347
     *
348
     * @throws \Propel\Runtime\Exception\PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
349
     *
350
     * @return ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Should the return type not be ModelCriteria?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
351
     */
352
    public function filterByPageLink($pageLink, $comparison = null)
353
    {
354
        if ($pageLink instanceof \mod_link\models\PageLink) {
355
            return $this
356
                ->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $pageLink->getId(), $comparison);
357
        } elseif ($pageLink instanceof ObjectCollection) {
358
            if (null === $comparison) {
359
                $comparison = Criteria::IN;
360
            }
361
362
            return $this
363
                ->addUsingAlias(PageLinkProductsTableMap::COL_LINK_ID, $pageLink->toKeyValue('PrimaryKey', 'Id'), $comparison);
364
        } else {
365
            throw new PropelException('filterByPageLink() only accepts arguments of type \mod_link\models\PageLink or Collection');
366
        }
367
    }
368
369
    /**
370
     * Adds a JOIN clause to the query using the PageLink relation
371
     *
372
     * @param     string $relationAlias optional alias for the relation
373
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
374
     *
375
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use PageLinkProductsQuery.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
376
     */
377
    public function joinPageLink($relationAlias = null, $joinType = Criteria::INNER_JOIN)
378
    {
379
        $tableMap = $this->getTableMap();
380
        $relationMap = $tableMap->getRelation('PageLink');
381
382
        // create a ModelJoin object for this join
383
        $join = new ModelJoin();
384
        $join->setJoinType($joinType);
385
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
386
        if ($previousJoin = $this->getPreviousJoin()) {
387
            $join->setPreviousJoin($previousJoin);
0 ignored issues
show
Compatibility introduced by
$previousJoin of type object<Propel\Runtime\ActiveQuery\Join> is not a sub-type of object<Propel\Runtime\ActiveQuery\ModelJoin>. It seems like you assume a child class of the class Propel\Runtime\ActiveQuery\Join to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
388
        }
389
390
        // add the ModelJoin to the current object
391
        if ($relationAlias) {
392
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
393
            $this->addJoinObject($join, $relationAlias);
394
        } else {
395
            $this->addJoinObject($join, 'PageLink');
396
        }
397
398
        return $this;
399
    }
400
401
    /**
402
     * Use the PageLink relation PageLink object
403
     *
404
     * @see useQuery()
405
     *
406
     * @param     string $relationAlias optional alias for the relation,
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
407
     *                                   to be used as main alias in the secondary query
0 ignored issues
show
introduced by
Parameter comment must start with a capital letter
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
408
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
409
     *
410
     * @return \mod_link\models\PageLinkQuery A secondary query class using the current class as primary query
411
     */
412
    public function usePageLinkQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
413
    {
414
        return $this
415
            ->joinPageLink($relationAlias, $joinType)
416
            ->useQuery($relationAlias ? $relationAlias : 'PageLink', '\mod_link\models\PageLinkQuery');
417
    }
418
419
    /**
420
     * Exclude object from result
421
     *
422
     * @param   ChildPageLinkProducts $pageLinkProducts Object to remove from the list of results
423
     *
424
     * @return $this|ChildPageLinkProductsQuery The current query, for fluid interface
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use PageLinkProductsQuery.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
introduced by
@return data type must not contain "$"
Loading history...
425
     */
426
    public function prune($pageLinkProducts = null)
427
    {
428
        if ($pageLinkProducts) {
429
            $this->addCond('pruneCond0', $this->getAliasedColName(PageLinkProductsTableMap::COL_LINK_ID), $pageLinkProducts->getLinkId(), Criteria::NOT_EQUAL);
430
            $this->addCond('pruneCond1', $this->getAliasedColName(PageLinkProductsTableMap::COL_PRODUCT_ID), $pageLinkProducts->getProductId(), Criteria::NOT_EQUAL);
431
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
432
        }
433
434
        return $this;
435
    }
436
437
    /**
438
     * Deletes all rows from the page_link_products table.
439
     *
440
     * @param ConnectionInterface $con the connection to use
441
     * @return int The number of affected rows (if supported by underlying database driver).
442
     */
443
    public function doDeleteAll(ConnectionInterface $con = null)
444
    {
445
        if (null === $con) {
446
            $con = Propel::getServiceContainer()->getWriteConnection(PageLinkProductsTableMap::DATABASE_NAME);
447
        }
448
449
        // use transaction because $criteria could contain info
450
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
451
        return $con->transaction(function () use ($con) {
452
            $affectedRows = 0; // initialize var to track total num of affected rows
453
            $affectedRows += parent::doDeleteAll($con);
454
            // Because this db requires some delete cascade/set null emulation, we have to
455
            // clear the cached instance *after* the emulation has happened (since
456
            // instances get re-added by the select statement contained therein).
457
            PageLinkProductsTableMap::clearInstancePool();
458
            PageLinkProductsTableMap::clearRelatedInstancePool();
459
460
            return $affectedRows;
461
        });
462
    }
463
464
    /**
465
     * Performs a DELETE on the database based on the current ModelCriteria
466
     *
467
     * @param ConnectionInterface $con the connection to use
468
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
469
     *                         if supported by native driver or if emulated using Propel.
470
     * @throws PropelException Any exceptions caught during processing will be
471
     *                         rethrown wrapped into a PropelException.
0 ignored issues
show
introduced by
@throws tag comment must start with a capital letter
Loading history...
472
     */
473
    public function delete(ConnectionInterface $con = null)
474
    {
475
        if (null === $con) {
476
            $con = Propel::getServiceContainer()->getWriteConnection(PageLinkProductsTableMap::DATABASE_NAME);
477
        }
478
479
        $criteria = $this;
480
481
        // Set the correct dbName
482
        $criteria->setDbName(PageLinkProductsTableMap::DATABASE_NAME);
483
484
        // use transaction because $criteria could contain info
485
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
486
        return $con->transaction(function () use ($con, $criteria) {
487
            $affectedRows = 0; // initialize var to track total num of affected rows
488
489
            PageLinkProductsTableMap::removeInstanceFromPool($criteria);
490
491
            $affectedRows += ModelCriteria::delete($con);
492
            PageLinkProductsTableMap::clearRelatedInstancePool();
493
494
            return $affectedRows;
495
        });
496
    }
497
498
} // PageLinkProductsQuery
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
499