return true;
}
- static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
- $failFunction = false, $flags = 0)
+ static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 )
{
return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags );
}
$union_unique = (preg_match('/\/\* UNION_UNIQUE \*\/ /', $sql) != 0);
//EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
//you have to select data from plan table after explain
+ $olderr = error_reporting(E_ERROR);
$explain_id = date('dmYHis');
+ error_reporting($olderr);
$sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \''.$explain_id.'\' FOR', $sql, 1, $explain_count);
$first = true;
foreach ($row as $col => $val) {
if ($first)
- $sql .= ':'.$col;
+ $sql .= $val !== NULL ? ':'.$col : 'NULL';
else
- $sql.= ', :'.$col;
+ $sql .= $val !== NULL ? ', :'.$col : ', NULL';
$first = false;
}
$sql .= ')';
- $stmt = oci_parse($this->mConn, $sql);
- foreach ($row as $col => $val) {
- if (!is_object($val)) {
- if (oci_bind_by_name($stmt, ":$col", $row[$col]) === false)
- $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
- }
- }
$stmt = oci_parse($this->mConn, $sql);
- foreach ($row as $col => $val) {
+ foreach ($row as $col => &$val) {
$col_type=$this->fieldInfo($this->tableName($table), $col)->type();
- if ($col_type != 'BLOB' && $col_type != 'CLOB') {
+
+ if ($val === NULL) {
+ // do nothing ... null was inserted in statement creation
+ } elseif ($col_type != 'BLOB' && $col_type != 'CLOB') {
if (is_object($val))
$val = $val->getData();
-
+
if (preg_match('/^timestamp.*/i', $col_type) == 1 && strtolower($val) == 'infinity')
$val = '31-12-2030 12:00:00.000000';
- if (oci_bind_by_name($stmt, ":$col", $wgLang->checkTitleEncoding($val)) === false)
+ $val = $wgLang->checkTitleEncoding($val);
+ if (oci_bind_by_name($stmt, ":$col", $val) === false)
$this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
} else {
if (($lob[$col] = oci_new_descriptor($this->mConn, OCI_D_LOB)) === false) {
}
}
}
-
+
$olderr = error_reporting(E_ERROR);
if (oci_execute($stmt, OCI_DEFAULT) === false) {
$e = oci_error($stmt);
return $size;
}
- function limitResult($sql, $limit, $offset) {
+ function limitResult( $sql, $limit, $offset=false ) {
if ($offset === false)
$offset = 0;
return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
}
- function unionQueries($sqls, $all = false) {
+ function unionQueries($sqls, $all) {
$glue = ' UNION ALL ';
return 'SELECT * '.($all?'':'/* UNION_UNIQUE */ ').'FROM ('.implode( $glue, $sqls ).')' ;
}
* Query whether a given column exists in the mediawiki schema
* based on prebuilt table to simulate MySQL field info and keep query speed minimal
*/
- function fieldExists( $table, $field ) {
+ function fieldExists( $table, $field, $fname = 'DatabaseOracle::fieldExists' ) {
if (!isset($this->fieldInfo_stmt))
$this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
if (!isset($this->fieldInfo_stmt))
$this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
- oci_bind_by_name($this->fieldInfo_stmt, ':tab', trim($table, '"'));
+ $table = trim($table, '"');
+ oci_bind_by_name($this->fieldInfo_stmt, ':tab', $table);
oci_bind_by_name($this->fieldInfo_stmt, ':col', $field);
if (oci_execute($this->fieldInfo_stmt, OCI_DEFAULT) === false) {
return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
}
- /* redundand ... will remove after confirming bitwise operations functionality
- public function makeList( $a, $mode = LIST_COMMA ) {
- if ( !is_array( $a ) ) {
- throw new DBUnexpectedError( $this, 'DatabaseOracle::makeList called with incorrect parameters' );
- }
- $a2 = array();
- foreach ($a as $key => $value) {
- if (strpos($key, ' & ') !== FALSE)
- $a2[preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $key)] = $value;
- elseif (strpos($key, ' | ') !== FALSE)
- $a2[preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $key)] = $value;
- elseif (!is_array($value)) {
- if (strpos($value, ' = ') !== FALSE) {
- if (strpos($value, ' & ') !== FALSE)
- $a2[$key] = preg_replace('/(.*)\s&\s(.*?)\s=\s(.*)/', 'BITAND($1, $2) = $3', $value);
- elseif (strpos($value, ' | ') !== FALSE)
- $a2[$key] = preg_replace('/(.*)\s|\s(.*?)\s=\s(.*)/', 'BITOR($1, $2) = $3', $value);
- else $a2[$key] = $value;
- }
- elseif (strpos($value, ' & ') !== FALSE)
- $a2[$key] = preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $value);
- elseif (strpos($value, ' | ') !== FALSE)
- $a2[$key] = preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $value);
- else
- $a2[$key] = $value;
- }
+ public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) {
+
+ $conds2 = array();
+ foreach($conds as $col=>$val) {
+ $col_type=$this->fieldInfo($this->tableName($table), $col)->type();
+ if ($col_type == 'CLOB')
+ $conds2['TO_CHAR('.$col.')'] = $val;
else
- $a2[$key] = $value;
+ $conds2[$col] = $val;
}
- return parent::makeList($a2, $mode);
+ return parent::delete( $table, $conds2, $fname );
}
- */
function bitNot($field) {
//expecting bit-fields smaller than 4bytes