Completed
Push — development ( 67765c...7029e6 )
by Andrij
18:12
created

RouteQuery::updateParentUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace core\models;
4
5
use core\models\Base\RouteQuery as BaseRouteQuery;
6
use core\models\Map\RouteTableMap;
7
use Propel\Runtime\ActiveQuery\Criteria;
8
use Propel\Runtime\Connection\Exception\ConnectionException;
9
use Propel\Runtime\Exception\PropelException;
10
use Propel\Runtime\Propel;
11
12
/**
13
 * Skeleton subclass for performing query and update operations on the 'route' table.
14
 *
15
 *
16
 *
17
 * You should add additional methods to this class to meet the
0 ignored issues
show
introduced by
There must be exactly one blank line between descriptions in a doc comment
Loading history...
18
 * application requirements.  This class will only be generated as
19
 * long as it does not already exist in the output directory.
20
 *
21
 */
0 ignored issues
show
introduced by
Additional blank lines found at end of doc comment
Loading history...
22
class RouteQuery extends BaseRouteQuery
23
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
24
25
    /**
26
     * @param string $old
27
     * @param string $new
28
     * @throws ConnectionException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
29
     */
30
    public function updateParentUrl($old, $new) {
31
32
        $connection = Propel::getWriteConnection(RouteTableMap::DATABASE_NAME);
33
        $sql = "UPDATE route SET parent_url = REPLACE(parent_url,:old,:new) WHERE parent_url LIKE CONCAT(:old ,'%')";
34
        $connection->prepare($sql)->execute([':old' => $old, ':new' => $new]);
35
36
    }
37
38
    /**
39
     * @param Route $route
40
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
41
     */
42
    public function deleteWithChildren(Route $route) {
43
        $this->filterByParentUrl($route->getFullUrl() . '%', Criteria::LIKE)->delete();
44
        $route->delete();
45
    }
46
47
}