Code Duplication    Length = 21-29 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabase.php 2 locations

@@ 102-122 (lines=21) @@
99
     *
100
     * @return string[][]
101
     */
102
    public function loadSectionData($id)
103
    {
104
        $query = $this->dbHandler->createSelectQuery();
105
        $query->select(
106
            $this->dbHandler->quoteColumn('id'),
107
            $this->dbHandler->quoteColumn('identifier'),
108
            $this->dbHandler->quoteColumn('name')
109
        )->from(
110
            $this->dbHandler->quoteTable('ezsection')
111
        )->where(
112
            $query->expr->eq(
113
                $this->dbHandler->quoteColumn('id'),
114
                $query->bindValue($id, null, \PDO::PARAM_INT)
115
            )
116
        );
117
118
        $statement = $query->prepare();
119
        $statement->execute();
120
121
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
122
    }
123
124
    /**
125
     * Loads data for all sections.
@@ 153-173 (lines=21) @@
150
     *
151
     * @return string[][]
152
     */
153
    public function loadSectionDataByIdentifier($identifier)
154
    {
155
        $query = $this->dbHandler->createSelectQuery();
156
        $query->select(
157
            $this->dbHandler->quoteColumn('id'),
158
            $this->dbHandler->quoteColumn('identifier'),
159
            $this->dbHandler->quoteColumn('name')
160
        )->from(
161
            $this->dbHandler->quoteTable('ezsection')
162
        )->where(
163
            $query->expr->eq(
164
                $this->dbHandler->quoteColumn('identifier'),
165
                $query->bindValue($identifier, null, \PDO::PARAM_STR)
166
            )
167
        );
168
169
        $statement = $query->prepare();
170
        $statement->execute();
171
172
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
173
    }
174
175
    /**
176
     * Counts the number of content objects assigned to section with $id.

eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php 1 location

@@ 683-711 (lines=29) @@
680
     *
681
     * @return mixed
682
     */
683
    public function getNextId()
684
    {
685
        $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
686
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
687
        $query = $this->dbHandler->createInsertQuery();
688
        $query->insertInto(
689
            $this->dbHandler->quoteTable('ezurlalias_ml_incr')
690
        );
691
        // ezcDatabase does not abstract the "auto increment id"
692
        // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
693
        // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
694
        // as a result we are forced to check which database is currently used
695
        // to generate the correct SQL query
696
        // see https://jira.ez.no/browse/EZP-20652
697
        if ($this->dbHandler->useSequences()) {
698
            $query->set(
699
                $this->dbHandler->quoteColumn('id'),
700
                "nextval('{$sequence}')"
701
            );
702
        } else {
703
            $query->set(
704
                $this->dbHandler->quoteColumn('id'),
705
                $query->bindValue(null, null, \PDO::PARAM_NULL)
706
            );
707
        }
708
        $query->prepare()->execute();
709
710
        return $this->dbHandler->lastInsertId($sequence);
711
    }
712
713
    /**
714
     * Loads single row data matched by composite primary key.