1
0

AdapterOCI8.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\DB;
  8. class AdapterOCI8 extends Adapter {
  9. public function lastInsertId($table) {
  10. if (is_null($table)) {
  11. throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
  12. }
  13. if ($table !== null) {
  14. $suffix = '_SEQ';
  15. $table = '"' . $table . $suffix . '"';
  16. }
  17. return $this->conn->realLastInsertId($table);
  18. }
  19. public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
  20. public function fixupStatement($statement) {
  21. $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
  22. $statement = str_replace('`', '"', $statement);
  23. $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
  24. $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
  25. return $statement;
  26. }
  27. }