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

@@ 599-627 (lines=29) @@
596
     *
597
     * @return mixed
598
     */
599
    public function getNextId()
600
    {
601
        $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
602
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
603
        $query = $this->dbHandler->createInsertQuery();
604
        $query->insertInto(
605
            $this->dbHandler->quoteTable('ezurlalias_ml_incr')
606
        );
607
        // ezcDatabase does not abstract the "auto increment id"
608
        // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
609
        // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
610
        // as a result we are forced to check which database is currently used
611
        // to generate the correct SQL query
612
        // see https://jira.ez.no/browse/EZP-20652
613
        if ($this->dbHandler->useSequences()) {
614
            $query->set(
615
                $this->dbHandler->quoteColumn('id'),
616
                "nextval('{$sequence}')"
617
            );
618
        } else {
619
            $query->set(
620
                $this->dbHandler->quoteColumn('id'),
621
                $query->bindValue(null, null, \PDO::PARAM_NULL)
622
            );
623
        }
624
        $query->prepare()->execute();
625
626
        return $this->dbHandler->lastInsertId($sequence);
627
    }
628
629
    /**
630
     * Loads single row data matched by composite primary key.