Code Duplication    Length = 22-22 lines in 2 locations

db/drivers/MysqlDriver.php 1 location

@@ 183-204 (lines=22) @@
180
     *
181
     * @return bool
182
     */
183
    public function update($table, array $elements = [], $conditions = '')
184
    {
185
        $keys = array_keys($elements);
186
187
        if (0 === count($keys)) {
188
            return false;
189
        }
190
191
        $valStr = [];
192
193
        foreach ($keys as $key) {
194
            $valStr[] = '`'.$key.'` = :'.$key;
195
        }
196
197
        $valStr = implode(',', $valStr);
198
199
        if ($conditions) {
200
            $conditions = 'WHERE '.$conditions;
201
        }
202
203
        return $this->conn->prepare("UPDATE {$table} SET {$valStr} {$conditions};")->execute($elements);
204
    }
205
206
    /**
207
     * Exists element in the table by params

db/drivers/PgsqlDriver.php 1 location

@@ 189-210 (lines=22) @@
186
     *
187
     * @return bool
188
     */
189
    public function update($table, array $elements = [], $conditions = '')
190
    {
191
        $keys = array_keys($elements);
192
193
        if (0 === count($keys)) {
194
            return false;
195
        }
196
197
        $valStr = [];
198
199
        foreach ($keys as $key) {
200
            $valStr[] = '"' . $key . '" = :' . $key;
201
        }
202
203
        $valStr = implode(',', $valStr);
204
205
        if ($conditions) {
206
            $conditions = 'WHERE ' . $conditions;
207
        }
208
209
        return $this->conn->prepare("UPDATE {$table} SET {$valStr} {$conditions};")->execute($elements);
210
    }
211
212
    /**
213
     * Exists element in the table by params