Code Duplication    Length = 21-29 lines in 3 locations

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

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

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

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