Code Duplication    Length = 30-31 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 910-940 (lines=31) @@
907
     * @return false|int
908
     *                   <p>false on error</p>
909
     */
910
    public function delete(string $table, $where, string $databaseName = null)
911
    {
912
        // init
913
        $table = \trim($table);
914
915
        if ($table === '') {
916
            $this->debug->displayError('Invalid table name, table name in empty.', false);
917
918
            return false;
919
        }
920
921
        if (\is_string($where)) {
922
            $WHERE = $this->escape($where, false);
923
        } elseif (\is_array($where)) {
924
            $WHERE = $this->_parseArrayPair($where, 'AND');
925
        } else {
926
            $WHERE = '';
927
        }
928
929
        if ($databaseName) {
930
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
931
        }
932
933
        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
934
935
        $return = $this->query($sql);
936
937
        \assert(\is_int($return) || $return === false);
938
939
        return $return;
940
    }
941
942
    /**
943
     * Ends a transaction and commits if no errors, then ends autocommit.
@@ 2300-2329 (lines=30) @@
2297
     * @return false|Result
2298
     *                      <p>false on error</p>
2299
     */
2300
    public function select(string $table, $where = '1=1', string $databaseName = null)
2301
    {
2302
        // init
2303
        $table = \trim($table);
2304
2305
        if ($table === '') {
2306
            $this->debug->displayError('Invalid table name, table name in empty.', false);
2307
2308
            return false;
2309
        }
2310
2311
        if (\is_string($where)) {
2312
            $WHERE = $this->escape($where, false);
2313
        } elseif (\is_array($where)) {
2314
            $WHERE = $this->_parseArrayPair($where, 'AND');
2315
        } else {
2316
            $WHERE = '';
2317
        }
2318
2319
        if ($databaseName) {
2320
            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2321
        }
2322
2323
        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2324
2325
        $return = $this->query($sql);
2326
        \assert($return instanceof Result || $return === false);
2327
2328
        return $return;
2329
    }
2330
2331
    /**
2332
     * Selects a different database than the one specified on construction.