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 classes like BannerImageQuery 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 BannerImageQuery, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 119 | abstract class BannerImageQuery extends ModelCriteria |
||
| 120 | { |
||
| 121 | protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Initializes internal state of \xbanners\models\Base\BannerImageQuery object. |
||
| 125 | * |
||
| 126 | * @param string $dbName The database name |
||
| 127 | * @param string $modelName The phpName of a model, e.g. 'Book' |
||
| 128 | * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
||
| 129 | */ |
||
| 130 | public function __construct($dbName = 'Shop', $modelName = '\\xbanners\\models\\BannerImage', $modelAlias = null) |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Returns a new ChildBannerImageQuery object. |
||
| 137 | * |
||
| 138 | * @param string $modelAlias The alias of a model in the query |
||
| 139 | * @param Criteria $criteria Optional Criteria to build the query from |
||
| 140 | * |
||
| 141 | * @return ChildBannerImageQuery |
||
| 142 | */ |
||
| 143 | View Code Duplication | public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 158 | |||
| 159 | /** |
||
| 160 | * Find object by primary key. |
||
| 161 | * Propel uses the instance pool to skip the database if the object exists. |
||
| 162 | * Go fast if the query is untouched. |
||
| 163 | * |
||
| 164 | * <code> |
||
| 165 | * $obj = $c->findPk(12, $con); |
||
| 166 | * </code> |
||
| 167 | * |
||
| 168 | * @param mixed $key Primary key to use for the query |
||
| 169 | * @param ConnectionInterface $con an optional connection object |
||
| 170 | * |
||
| 171 | * @return ChildBannerImage|array|mixed the result, formatted by the current formatter |
||
| 172 | */ |
||
| 173 | View Code Duplication | public function findPk($key, ConnectionInterface $con = null) |
|
| 174 | { |
||
| 175 | if ($key === null) { |
||
| 176 | return null; |
||
| 177 | } |
||
| 178 | |||
| 179 | if ($con === null) { |
||
| 180 | $con = Propel::getServiceContainer()->getReadConnection(BannerImageTableMap::DATABASE_NAME); |
||
| 181 | } |
||
| 182 | |||
| 183 | $this->basePreSelect($con); |
||
| 184 | |||
| 185 | if ( |
||
| 186 | $this->formatter || $this->modelAlias || $this->with || $this->select |
||
| 187 | || $this->selectColumns || $this->asColumns || $this->selectModifiers |
||
| 188 | || $this->map || $this->having || $this->joins |
||
| 189 | ) { |
||
| 190 | return $this->findPkComplex($key, $con); |
||
| 191 | } |
||
| 192 | |||
| 193 | if ((null !== ($obj = BannerImageTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key)))) { |
||
| 194 | // the object is already in the instance pool |
||
| 195 | return $obj; |
||
| 196 | } |
||
| 197 | |||
| 198 | return $this->findPkSimple($key, $con); |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Find object by primary key using raw SQL to go fast. |
||
| 203 | * Bypass doSelect() and the object formatter by using generated code. |
||
| 204 | * |
||
| 205 | * @param mixed $key Primary key to use for the query |
||
| 206 | * @param ConnectionInterface $con A connection object |
||
| 207 | * |
||
| 208 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 209 | * |
||
| 210 | * @return ChildBannerImage A model object, or null if the key is not found |
||
| 211 | */ |
||
| 212 | View Code Duplication | protected function findPkSimple($key, ConnectionInterface $con) |
|
| 234 | |||
| 235 | /** |
||
| 236 | * Find object by primary key. |
||
| 237 | * |
||
| 238 | * @param mixed $key Primary key to use for the query |
||
| 239 | * @param ConnectionInterface $con A connection object |
||
| 240 | * |
||
| 241 | * @return ChildBannerImage|array|mixed the result, formatted by the current formatter |
||
| 242 | */ |
||
| 243 | protected function findPkComplex($key, ConnectionInterface $con) |
||
| 244 | { |
||
| 245 | // As the query uses a PK condition, no limit(1) is necessary. |
||
| 246 | $criteria = $this->isKeepQuery() ? clone $this : $this; |
||
| 247 | $dataFetcher = $criteria |
||
| 248 | ->filterByPrimaryKey($key) |
||
| 249 | ->doSelect($con); |
||
| 250 | |||
| 251 | return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
||
| 252 | } |
||
| 253 | |||
| 254 | /** |
||
| 255 | * Find objects by primary key |
||
| 256 | * <code> |
||
| 257 | * $objs = $c->findPks(array(12, 56, 832), $con); |
||
| 258 | * </code> |
||
| 259 | * @param array $keys Primary keys to use for the query |
||
| 260 | * @param ConnectionInterface $con an optional connection object |
||
| 261 | * |
||
| 262 | * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
||
| 263 | */ |
||
| 264 | public function findPks($keys, ConnectionInterface $con = null) |
||
| 265 | { |
||
| 266 | if (null === $con) { |
||
| 267 | $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
||
| 268 | } |
||
| 269 | $this->basePreSelect($con); |
||
| 270 | $criteria = $this->isKeepQuery() ? clone $this : $this; |
||
| 271 | $dataFetcher = $criteria |
||
| 272 | ->filterByPrimaryKeys($keys) |
||
| 273 | ->doSelect($con); |
||
| 274 | |||
| 275 | return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Filter the query by primary key |
||
| 280 | * |
||
| 281 | * @param mixed $key Primary key to use for the query |
||
| 282 | * |
||
| 283 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 284 | */ |
||
| 285 | public function filterByPrimaryKey($key) |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Filter the query by a list of primary keys |
||
| 293 | * |
||
| 294 | * @param array $keys The list of primary key to use for the query |
||
| 295 | * |
||
| 296 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 297 | */ |
||
| 298 | public function filterByPrimaryKeys($keys) |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Filter the query on the id column |
||
| 306 | * |
||
| 307 | * Example usage: |
||
| 308 | * <code> |
||
| 309 | * $query->filterById(1234); // WHERE id = 1234 |
||
| 310 | * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
||
| 311 | * $query->filterById(array('min' => 12)); // WHERE id > 12 |
||
| 312 | * </code> |
||
| 313 | * |
||
| 314 | * @param mixed $id The value to use as filter. |
||
| 315 | * Use scalar values for equality. |
||
| 316 | * Use array values for in_array() equivalent. |
||
| 317 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 318 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 319 | * |
||
| 320 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 321 | */ |
||
| 322 | View Code Duplication | public function filterById($id = null, $comparison = null) |
|
| 344 | |||
| 345 | /** |
||
| 346 | * Filter the query on the banner_id column |
||
| 347 | * |
||
| 348 | * Example usage: |
||
| 349 | * <code> |
||
| 350 | * $query->filterByBannerId(1234); // WHERE banner_id = 1234 |
||
| 351 | * $query->filterByBannerId(array(12, 34)); // WHERE banner_id IN (12, 34) |
||
| 352 | * $query->filterByBannerId(array('min' => 12)); // WHERE banner_id > 12 |
||
| 353 | * </code> |
||
| 354 | * |
||
| 355 | * @see filterByBanners() |
||
| 356 | * |
||
| 357 | * @param mixed $bannerId The value to use as filter. |
||
| 358 | * Use scalar values for equality. |
||
| 359 | * Use array values for in_array() equivalent. |
||
| 360 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 361 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 362 | * |
||
| 363 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 364 | */ |
||
| 365 | View Code Duplication | public function filterByBannerId($bannerId = null, $comparison = null) |
|
| 387 | |||
| 388 | /** |
||
| 389 | * Filter the query on the target column |
||
| 390 | * |
||
| 391 | * Example usage: |
||
| 392 | * <code> |
||
| 393 | * $query->filterByTarget(1234); // WHERE target = 1234 |
||
| 394 | * $query->filterByTarget(array(12, 34)); // WHERE target IN (12, 34) |
||
| 395 | * $query->filterByTarget(array('min' => 12)); // WHERE target > 12 |
||
| 396 | * </code> |
||
| 397 | * |
||
| 398 | * @param mixed $target The value to use as filter. |
||
| 399 | * Use scalar values for equality. |
||
| 400 | * Use array values for in_array() equivalent. |
||
| 401 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 402 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 403 | * |
||
| 404 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 405 | */ |
||
| 406 | View Code Duplication | public function filterByTarget($target = null, $comparison = null) |
|
| 428 | |||
| 429 | /** |
||
| 430 | * Filter the query on the url column |
||
| 431 | * |
||
| 432 | * Example usage: |
||
| 433 | * <code> |
||
| 434 | * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' |
||
| 435 | * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' |
||
| 436 | * </code> |
||
| 437 | * |
||
| 438 | * @param string $url The value to use as filter. |
||
| 439 | * Accepts wildcards (* and % trigger a LIKE) |
||
| 440 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 441 | * |
||
| 442 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 443 | */ |
||
| 444 | View Code Duplication | public function filterByUrl($url = null, $comparison = null) |
|
| 445 | { |
||
| 446 | if (null === $comparison) { |
||
| 447 | if (is_array($url)) { |
||
| 448 | $comparison = Criteria::IN; |
||
| 449 | } elseif (preg_match('/[\%\*]/', $url)) { |
||
| 450 | $url = str_replace('*', '%', $url); |
||
| 451 | $comparison = Criteria::LIKE; |
||
| 452 | } |
||
| 453 | } |
||
| 454 | |||
| 455 | return $this->addUsingAlias(BannerImageTableMap::COL_URL, $url, $comparison); |
||
| 456 | } |
||
| 457 | |||
| 458 | /** |
||
| 459 | * Filter the query on the allowed_page column |
||
| 460 | * |
||
| 461 | * Example usage: |
||
| 462 | * <code> |
||
| 463 | * $query->filterByAllowedPage(1234); // WHERE allowed_page = 1234 |
||
| 464 | * $query->filterByAllowedPage(array(12, 34)); // WHERE allowed_page IN (12, 34) |
||
| 465 | * $query->filterByAllowedPage(array('min' => 12)); // WHERE allowed_page > 12 |
||
| 466 | * </code> |
||
| 467 | * |
||
| 468 | * @param mixed $allowedPage The value to use as filter. |
||
| 469 | * Use scalar values for equality. |
||
| 470 | * Use array values for in_array() equivalent. |
||
| 471 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 472 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 473 | * |
||
| 474 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 475 | */ |
||
| 476 | View Code Duplication | public function filterByAllowedPage($allowedPage = null, $comparison = null) |
|
| 498 | |||
| 499 | /** |
||
| 500 | * Filter the query on the position column |
||
| 501 | * |
||
| 502 | * Example usage: |
||
| 503 | * <code> |
||
| 504 | * $query->filterByPosition(1234); // WHERE position = 1234 |
||
| 505 | * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) |
||
| 506 | * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 |
||
| 507 | * </code> |
||
| 508 | * |
||
| 509 | * @param mixed $position The value to use as filter. |
||
| 510 | * Use scalar values for equality. |
||
| 511 | * Use array values for in_array() equivalent. |
||
| 512 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 513 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 514 | * |
||
| 515 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 516 | */ |
||
| 517 | View Code Duplication | public function filterByPosition($position = null, $comparison = null) |
|
| 539 | |||
| 540 | /** |
||
| 541 | * Filter the query on the active_from column |
||
| 542 | * |
||
| 543 | * Example usage: |
||
| 544 | * <code> |
||
| 545 | * $query->filterByActiveFrom(1234); // WHERE active_from = 1234 |
||
| 546 | * $query->filterByActiveFrom(array(12, 34)); // WHERE active_from IN (12, 34) |
||
| 547 | * $query->filterByActiveFrom(array('min' => 12)); // WHERE active_from > 12 |
||
| 548 | * </code> |
||
| 549 | * |
||
| 550 | * @param mixed $activeFrom The value to use as filter. |
||
| 551 | * Use scalar values for equality. |
||
| 552 | * Use array values for in_array() equivalent. |
||
| 553 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 554 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 555 | * |
||
| 556 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 557 | */ |
||
| 558 | View Code Duplication | public function filterByActiveFrom($activeFrom = null, $comparison = null) |
|
| 580 | |||
| 581 | /** |
||
| 582 | * Filter the query on the active_to column |
||
| 583 | * |
||
| 584 | * Example usage: |
||
| 585 | * <code> |
||
| 586 | * $query->filterByActiveTo(1234); // WHERE active_to = 1234 |
||
| 587 | * $query->filterByActiveTo(array(12, 34)); // WHERE active_to IN (12, 34) |
||
| 588 | * $query->filterByActiveTo(array('min' => 12)); // WHERE active_to > 12 |
||
| 589 | * </code> |
||
| 590 | * |
||
| 591 | * @param mixed $activeTo The value to use as filter. |
||
| 592 | * Use scalar values for equality. |
||
| 593 | * Use array values for in_array() equivalent. |
||
| 594 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 595 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 596 | * |
||
| 597 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 598 | */ |
||
| 599 | View Code Duplication | public function filterByActiveTo($activeTo = null, $comparison = null) |
|
| 621 | |||
| 622 | /** |
||
| 623 | * Filter the query on the active column |
||
| 624 | * |
||
| 625 | * Example usage: |
||
| 626 | * <code> |
||
| 627 | * $query->filterByActive(1234); // WHERE active = 1234 |
||
| 628 | * $query->filterByActive(array(12, 34)); // WHERE active IN (12, 34) |
||
| 629 | * $query->filterByActive(array('min' => 12)); // WHERE active > 12 |
||
| 630 | * </code> |
||
| 631 | * |
||
| 632 | * @param mixed $active The value to use as filter. |
||
| 633 | * Use scalar values for equality. |
||
| 634 | * Use array values for in_array() equivalent. |
||
| 635 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 636 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 637 | * |
||
| 638 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 639 | */ |
||
| 640 | View Code Duplication | public function filterByActive($active = null, $comparison = null) |
|
| 662 | |||
| 663 | /** |
||
| 664 | * Filter the query on the permanent column |
||
| 665 | * |
||
| 666 | * Example usage: |
||
| 667 | * <code> |
||
| 668 | * $query->filterByPermanent(1234); // WHERE permanent = 1234 |
||
| 669 | * $query->filterByPermanent(array(12, 34)); // WHERE permanent IN (12, 34) |
||
| 670 | * $query->filterByPermanent(array('min' => 12)); // WHERE permanent > 12 |
||
| 671 | * </code> |
||
| 672 | * |
||
| 673 | * @param mixed $permanent The value to use as filter. |
||
| 674 | * Use scalar values for equality. |
||
| 675 | * Use array values for in_array() equivalent. |
||
| 676 | * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
||
| 677 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 678 | * |
||
| 679 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 680 | */ |
||
| 681 | View Code Duplication | public function filterByPermanent($permanent = null, $comparison = null) |
|
| 703 | |||
| 704 | /** |
||
| 705 | * Filter the query by a related \xbanners\models\Banners object |
||
| 706 | * |
||
| 707 | * @param \xbanners\models\Banners|ObjectCollection $banners The related object(s) to use as filter |
||
| 708 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 709 | * |
||
| 710 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 711 | * |
||
| 712 | * @return ChildBannerImageQuery The current query, for fluid interface |
||
| 713 | */ |
||
| 714 | public function filterByBanners($banners, $comparison = null) |
||
| 715 | { |
||
| 716 | if ($banners instanceof \xbanners\models\Banners) { |
||
| 717 | return $this |
||
| 718 | ->addUsingAlias(BannerImageTableMap::COL_BANNER_ID, $banners->getId(), $comparison); |
||
| 719 | } elseif ($banners instanceof ObjectCollection) { |
||
| 720 | if (null === $comparison) { |
||
| 721 | $comparison = Criteria::IN; |
||
| 722 | } |
||
| 723 | |||
| 724 | return $this |
||
| 725 | ->addUsingAlias(BannerImageTableMap::COL_BANNER_ID, $banners->toKeyValue('PrimaryKey', 'Id'), $comparison); |
||
| 726 | } else { |
||
| 727 | throw new PropelException('filterByBanners() only accepts arguments of type \xbanners\models\Banners or Collection'); |
||
| 728 | } |
||
| 729 | } |
||
| 730 | |||
| 731 | /** |
||
| 732 | * Adds a JOIN clause to the query using the Banners relation |
||
| 733 | * |
||
| 734 | * @param string $relationAlias optional alias for the relation |
||
| 735 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 736 | * |
||
| 737 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 738 | */ |
||
| 739 | public function joinBanners($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
||
| 740 | { |
||
| 741 | $tableMap = $this->getTableMap(); |
||
| 742 | $relationMap = $tableMap->getRelation('Banners'); |
||
| 743 | |||
| 744 | // create a ModelJoin object for this join |
||
| 745 | $join = new ModelJoin(); |
||
| 746 | $join->setJoinType($joinType); |
||
| 747 | $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
||
| 748 | if ($previousJoin = $this->getPreviousJoin()) { |
||
| 749 | $join->setPreviousJoin($previousJoin); |
||
| 750 | } |
||
| 751 | |||
| 752 | // add the ModelJoin to the current object |
||
| 753 | if ($relationAlias) { |
||
| 754 | $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
||
| 755 | $this->addJoinObject($join, $relationAlias); |
||
| 756 | } else { |
||
| 757 | $this->addJoinObject($join, 'Banners'); |
||
| 758 | } |
||
| 759 | |||
| 760 | return $this; |
||
| 761 | } |
||
| 762 | |||
| 763 | /** |
||
| 764 | * Use the Banners relation Banners object |
||
| 765 | * |
||
| 766 | * @see useQuery() |
||
| 767 | * |
||
| 768 | * @param string $relationAlias optional alias for the relation, |
||
| 769 | * to be used as main alias in the secondary query |
||
| 770 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 771 | * |
||
| 772 | * @return \xbanners\models\BannersQuery A secondary query class using the current class as primary query |
||
| 773 | */ |
||
| 774 | public function useBannersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Filter the query by a related \xbanners\models\BannerImageI18n object |
||
| 783 | * |
||
| 784 | * @param \xbanners\models\BannerImageI18n|ObjectCollection $bannerImageI18n the related object to use as filter |
||
| 785 | * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
||
| 786 | * |
||
| 787 | * @return ChildBannerImageQuery The current query, for fluid interface |
||
| 788 | */ |
||
| 789 | View Code Duplication | public function filterByBannerImageI18n($bannerImageI18n, $comparison = null) |
|
| 803 | |||
| 804 | /** |
||
| 805 | * Adds a JOIN clause to the query using the BannerImageI18n relation |
||
| 806 | * |
||
| 807 | * @param string $relationAlias optional alias for the relation |
||
| 808 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 809 | * |
||
| 810 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 811 | */ |
||
| 812 | public function joinBannerImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') |
||
| 813 | { |
||
| 814 | $tableMap = $this->getTableMap(); |
||
| 815 | $relationMap = $tableMap->getRelation('BannerImageI18n'); |
||
| 816 | |||
| 817 | // create a ModelJoin object for this join |
||
| 818 | $join = new ModelJoin(); |
||
| 819 | $join->setJoinType($joinType); |
||
| 820 | $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
||
| 821 | if ($previousJoin = $this->getPreviousJoin()) { |
||
| 822 | $join->setPreviousJoin($previousJoin); |
||
| 823 | } |
||
| 824 | |||
| 825 | // add the ModelJoin to the current object |
||
| 826 | if ($relationAlias) { |
||
| 827 | $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
||
| 828 | $this->addJoinObject($join, $relationAlias); |
||
| 829 | } else { |
||
| 830 | $this->addJoinObject($join, 'BannerImageI18n'); |
||
| 831 | } |
||
| 832 | |||
| 833 | return $this; |
||
| 834 | } |
||
| 835 | |||
| 836 | /** |
||
| 837 | * Use the BannerImageI18n relation BannerImageI18n object |
||
| 838 | * |
||
| 839 | * @see useQuery() |
||
| 840 | * |
||
| 841 | * @param string $relationAlias optional alias for the relation, |
||
| 842 | * to be used as main alias in the secondary query |
||
| 843 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
||
| 844 | * |
||
| 845 | * @return \xbanners\models\BannerImageI18nQuery A secondary query class using the current class as primary query |
||
| 846 | */ |
||
| 847 | public function useBannerImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') |
||
| 853 | |||
| 854 | /** |
||
| 855 | * Exclude object from result |
||
| 856 | * |
||
| 857 | * @param ChildBannerImage $bannerImage Object to remove from the list of results |
||
| 858 | * |
||
| 859 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 860 | */ |
||
| 861 | public function prune($bannerImage = null) |
||
| 869 | |||
| 870 | /** |
||
| 871 | * Deletes all rows from the banner_image table. |
||
| 872 | * |
||
| 873 | * @param ConnectionInterface $con the connection to use |
||
| 874 | * @return int The number of affected rows (if supported by underlying database driver). |
||
| 875 | */ |
||
| 876 | public function doDeleteAll(ConnectionInterface $con = null) |
||
| 877 | { |
||
| 878 | if (null === $con) { |
||
| 879 | $con = Propel::getServiceContainer()->getWriteConnection(BannerImageTableMap::DATABASE_NAME); |
||
| 880 | } |
||
| 881 | |||
| 882 | // use transaction because $criteria could contain info |
||
| 883 | // for more than one table or we could emulating ON DELETE CASCADE, etc. |
||
| 884 | return $con->transaction(function () use ($con) { |
||
| 885 | $affectedRows = 0; // initialize var to track total num of affected rows |
||
| 886 | $affectedRows += $this->doOnDeleteCascade($con); |
||
| 887 | $affectedRows += parent::doDeleteAll($con); |
||
| 888 | // Because this db requires some delete cascade/set null emulation, we have to |
||
| 889 | // clear the cached instance *after* the emulation has happened (since |
||
| 890 | // instances get re-added by the select statement contained therein). |
||
| 891 | BannerImageTableMap::clearInstancePool(); |
||
| 892 | BannerImageTableMap::clearRelatedInstancePool(); |
||
| 893 | |||
| 894 | return $affectedRows; |
||
| 895 | }); |
||
| 896 | } |
||
| 897 | |||
| 898 | /** |
||
| 899 | * Performs a DELETE on the database based on the current ModelCriteria |
||
| 900 | * |
||
| 901 | * @param ConnectionInterface $con the connection to use |
||
| 902 | * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
||
| 903 | * if supported by native driver or if emulated using Propel. |
||
| 904 | * @throws PropelException Any exceptions caught during processing will be |
||
| 905 | * rethrown wrapped into a PropelException. |
||
| 906 | */ |
||
| 907 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 935 | |||
| 936 | /** |
||
| 937 | * This is a method for emulating ON DELETE CASCADE for DBs that don't support this |
||
| 938 | * feature (like MySQL or SQLite). |
||
| 939 | * |
||
| 940 | * This method is not very speedy because it must perform a query first to get |
||
| 941 | * the implicated records and then perform the deletes by calling those Query classes. |
||
| 942 | * |
||
| 943 | * This method should be used within a transaction if possible. |
||
| 944 | * |
||
| 945 | * @param ConnectionInterface $con |
||
| 946 | * @return int The number of affected rows (if supported by underlying database driver). |
||
| 947 | */ |
||
| 948 | protected function doOnDeleteCascade(ConnectionInterface $con) |
||
| 967 | |||
| 968 | // i18n behavior |
||
| 969 | |||
| 970 | /** |
||
| 971 | * Adds a JOIN clause to the query using the i18n relation |
||
| 972 | * |
||
| 973 | * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' |
||
| 974 | * @param string $relationAlias optional alias for the relation |
||
| 975 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. |
||
| 976 | * |
||
| 977 | * @return ChildBannerImageQuery The current query, for fluid interface |
||
| 978 | */ |
||
| 979 | View Code Duplication | public function joinI18n($locale = 'ru', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 987 | |||
| 988 | /** |
||
| 989 | * Adds a JOIN clause to the query and hydrates the related I18n object. |
||
| 990 | * Shortcut for $c->joinI18n($locale)->with() |
||
| 991 | * |
||
| 992 | * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' |
||
| 993 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. |
||
| 994 | * |
||
| 995 | * @return $this|ChildBannerImageQuery The current query, for fluid interface |
||
| 996 | */ |
||
| 997 | View Code Duplication | public function joinWithI18n($locale = 'ru', $joinType = Criteria::LEFT_JOIN) |
|
| 1006 | |||
| 1007 | /** |
||
| 1008 | * Use the I18n relation query object |
||
| 1009 | * |
||
| 1010 | * @see useQuery() |
||
| 1011 | * |
||
| 1012 | * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' |
||
| 1013 | * @param string $relationAlias optional alias for the relation |
||
| 1014 | * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. |
||
| 1015 | * |
||
| 1016 | * @return ChildBannerImageI18nQuery A secondary query class using the current class as primary query |
||
| 1017 | */ |
||
| 1018 | public function useI18nQuery($locale = 'ru', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
||
| 1024 | |||
| 1025 | } // BannerImageQuery |
||
| 1026 |