X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdb%2FDatabaseOracle.php;h=90fabaf5c4383f15a2a2093e456b5448e5b35610;hp=b72878689644cc58fd50becdf1dd2b761d30cee9;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hpb=cf35ff756c89ca6d6e003b440076df5ebe7ccef7 diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index b728786896..90fabaf5c4 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -37,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; @@ -319,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]; } /** @@ -359,7 +354,7 @@ class DatabaseOracle extends Database { return $e['code']; } - function affectedRows() { + protected function fetchAffectedRowCount() { return $this->mAffectedRows; } @@ -558,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 && @@ -585,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; @@ -656,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 *