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

@@ 639-667 (lines=29) @@
636
     *
637
     * @return mixed
638
     */
639
    public function getNextId()
640
    {
641
        $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
642
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
643
        $query = $this->dbHandler->createInsertQuery();
644
        $query->insertInto(
645
            $this->dbHandler->quoteTable('ezurlalias_ml_incr')
646
        );
647
        // ezcDatabase does not abstract the "auto increment id"
648
        // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
649
        // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
650
        // as a result we are forced to check which database is currently used
651
        // to generate the correct SQL query
652
        // see https://jira.ez.no/browse/EZP-20652
653
        if ($this->dbHandler->useSequences()) {
654
            $query->set(
655
                $this->dbHandler->quoteColumn('id'),
656
                "nextval('{$sequence}')"
657
            );
658
        } else {
659
            $query->set(
660
                $this->dbHandler->quoteColumn('id'),
661
                $query->bindValue(null, null, \PDO::PARAM_NULL)
662
            );
663
        }
664
        $query->prepare()->execute();
665
666
        return $this->dbHandler->lastInsertId($sequence);
667
    }
668
669
    /**
670
     * Loads single row data matched by composite primary key.