X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseOracle.php;h=b72878689644cc58fd50becdf1dd2b761d30cee9;hb=74426f3cf796b149f1ae445e41815bbe148640b2;hp=344aa3d939c326f957cfd261e8378b1260cda7e3;hpb=32ed9feb39c5acfadf33d34b66cb70bd2ff01d16;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 344aa3d939..90fabaf5c4 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -20,7 +20,12 @@ * @file * @ingroup Database */ + +use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\Blob; +use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\DBConnectionError; +use Wikimedia\Rdbms\DBUnexpectedError; /** * @ingroup Database @@ -32,9 +37,6 @@ class DatabaseOracle extends Database { /** @var int The number of rows affected as an integer */ protected $mAffectedRows; - /** @var int */ - private $mInsertId = null; - /** @var bool */ private $ignoreDupValOnIndex = false; @@ -314,12 +316,10 @@ class DatabaseOracle extends Database { return oci_field_name( $stmt, $n ); } - /** - * This must be called after nextSequenceVal - * @return null|int - */ function insertId() { - return $this->mInsertId; + $res = $this->query( "SELECT lastval_pkg.getLastval FROM dual" ); + $row = $this->fetchRow( $res ); + return is_null( $row[0] ) ? null : (int)$row[0]; } /** @@ -354,7 +354,7 @@ class DatabaseOracle extends Database { return $e['code']; } - function affectedRows() { + protected function fetchAffectedRowCount() { return $this->mAffectedRows; } @@ -553,19 +553,9 @@ class DatabaseOracle extends Database { } function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__, - $insertOptions = [], $selectOptions = [] + $insertOptions = [], $selectOptions = [], $selectJoinConds = [] ) { $destTable = $this->tableName( $destTable ); - if ( !is_array( $selectOptions ) ) { - $selectOptions = [ $selectOptions ]; - } - list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) = - $this->makeSelectOptions( $selectOptions ); - if ( is_array( $srcTable ) ) { - $srcTable = implode( ',', array_map( [ $this, 'tableName' ], $srcTable ) ); - } else { - $srcTable = $this->tableName( $srcTable ); - } $sequenceData = $this->getSequenceData( $destTable ); if ( $sequenceData !== false && @@ -580,13 +570,16 @@ class DatabaseOracle extends Database { $val = $val . ' field' . ( $i++ ); } - $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . - " SELECT $startOpts " . implode( ',', $varMap ) . - " FROM $srcTable $useIndex $ignoreIndex "; - if ( $conds != '*' ) { - $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); - } - $sql .= " $tailOpts"; + $selectSql = $this->selectSQLText( + $srcTable, + array_values( $varMap ), + $conds, + $fname, + $selectOptions, + $selectJoinConds + ); + + $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ') ' . $selectSql; if ( in_array( 'IGNORE', $insertOptions ) ) { $this->ignoreDupValOnIndex = true; @@ -651,20 +644,6 @@ class DatabaseOracle extends Database { return preg_replace( '/.*\.(.*)/', '$1', $name ); } - /** - * Return the next in a sequence, save the value for retrieval via insertId() - * - * @param string $seqName - * @return null|int - */ - function nextSequenceValue( $seqName ) { - $res = $this->query( "SELECT $seqName.nextval FROM dual" ); - $row = $this->fetchRow( $res ); - $this->mInsertId = $row[0]; - - return $this->mInsertId; - } - /** * Return sequence_name if table has a sequence *