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

@@ 702-730 (lines=29) @@
699
     *
700
     * @return mixed
701
     */
702
    public function getNextId()
703
    {
704
        $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
705
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
706
        $query = $this->dbHandler->createInsertQuery();
707
        $query->insertInto(
708
            $this->dbHandler->quoteTable('ezurlalias_ml_incr')
709
        );
710
        // ezcDatabase does not abstract the "auto increment id"
711
        // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
712
        // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
713
        // as a result we are forced to check which database is currently used
714
        // to generate the correct SQL query
715
        // see https://jira.ez.no/browse/EZP-20652
716
        if ($this->dbHandler->useSequences()) {
717
            $query->set(
718
                $this->dbHandler->quoteColumn('id'),
719
                "nextval('{$sequence}')"
720
            );
721
        } else {
722
            $query->set(
723
                $this->dbHandler->quoteColumn('id'),
724
                $query->bindValue(null, null, \PDO::PARAM_NULL)
725
            );
726
        }
727
        $query->prepare()->execute();
728
729
        return (int)$this->dbHandler->lastInsertId($sequence);
730
    }
731
732
    /**
733
     * Loads single row data matched by composite primary key.