0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-22 05:51:35 +00:00
nextcloud_server/lib/private/DB/AdapterOCI8.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.8 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\DB;
class AdapterOCI8 extends Adapter {
2013-03-22 18:36:40 +01:00
public function lastInsertId($table) {
if (is_null($table)) {
throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
}
2014-09-09 13:57:02 +02:00
if ($table !== null) {
2013-03-22 18:36:40 +01:00
$suffix = '_SEQ';
2014-09-09 13:57:02 +02:00
$table = '"' . $table . $suffix . '"';
2013-03-22 18:36:40 +01:00
}
2013-07-23 22:16:04 +02:00
return $this->conn->realLastInsertId($table);
2013-03-22 18:36:40 +01:00
}
public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
2014-09-09 13:57:02 +02:00
public function fixupStatement($statement) {
2014-09-18 15:09:57 +02:00
$statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
2014-09-09 13:57:02 +02:00
$statement = str_replace('`', '"', $statement);
$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
if (\str_contains($statement, 'filecache')) {
$statement = preg_replace(
'/^INSERT (INTO .+ VALUES ?\(.+\))$/',
'INSERT ${1} RETURNING "fileid" INTO "vRowid"',
$statement
);
var_dump($statement);
} elseif (\str_contains($statement, 'addressbooks')) {
$statement = preg_replace(
'/^INSERT (INTO .+)$/',
'DECLARE vRowid NUMBER; BEGIN INSERT INTO ${1} RETURNING "id" INTO vRowid; dbms_output.put_line(vRowid); END;',
$statement
);
var_dump($statement);
} elseif (\str_contains($statement, 'storages')) {
$statement = preg_replace(
'/^INSERT (INTO .+)$/',
'DECLARE vRowid NUMBER; BEGIN INSERT INTO ${1} RETURNING "numeric_id" INTO vRowid; dbms_output.put_line(vRowid); END;',
$statement
);
var_dump($statement);
}
return $statement;
}
}