Code Duplication    Length = 21-29 lines in 3 locations

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

@@ 103-123 (lines=21) @@
100
     *
101
     * @return string[][]
102
     */
103
    public function loadSectionData($id)
104
    {
105
        $query = $this->dbHandler->createSelectQuery();
106
        $query->select(
107
            $this->dbHandler->quoteColumn('id'),
108
            $this->dbHandler->quoteColumn('identifier'),
109
            $this->dbHandler->quoteColumn('name')
110
        )->from(
111
            $this->dbHandler->quoteTable('ezsection')
112
        )->where(
113
            $query->expr->eq(
114
                $this->dbHandler->quoteColumn('id'),
115
                $query->bindValue($id, null, \PDO::PARAM_INT)
116
            )
117
        );
118
119
        $statement = $query->prepare();
120
        $statement->execute();
121
122
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
123
    }
124
125
    /**
126
     * Loads data for all sections.
@@ 154-174 (lines=21) @@
151
     *
152
     * @return string[][]
153
     */
154
    public function loadSectionDataByIdentifier($identifier)
155
    {
156
        $query = $this->dbHandler->createSelectQuery();
157
        $query->select(
158
            $this->dbHandler->quoteColumn('id'),
159
            $this->dbHandler->quoteColumn('identifier'),
160
            $this->dbHandler->quoteColumn('name')
161
        )->from(
162
            $this->dbHandler->quoteTable('ezsection')
163
        )->where(
164
            $query->expr->eq(
165
                $this->dbHandler->quoteColumn('identifier'),
166
                $query->bindValue($identifier, null, \PDO::PARAM_STR)
167
            )
168
        );
169
170
        $statement = $query->prepare();
171
        $statement->execute();
172
173
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
174
    }
175
176
    /**
177
     * 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 (int)$this->dbHandler->lastInsertId($sequence);
713
    }
714
715
    /**
716
     * Loads single row data matched by composite primary key.