5 include_once (
"./Services/Database/classes/class.ilDB.php");
31 if(!isset(
$GLOBALS[
'_MDB2_dsninfo_default'][
'charset']) or
32 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] !=
'utf8')
34 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] =
'utf8';
37 return array(
'phptype' =>
'oci8',
59 $query =
'SELECT * FROM v$version';
78 "ACCESS",
"ADD",
"ALL",
"ALTER",
"AND",
"ANY",
"AS",
"ASC",
79 "AUDIT",
"BETWEEN",
"BY",
"CHAR",
"CHECK",
"CLUSTER",
"COLUMN",
80 "COMMENT",
"COMPRESS",
"CONNECT",
"CREATE",
"CURRENT",
"DATE",
81 "DECIMAL",
"DEFAULT",
"DELETE",
"DESC",
"DISTINCT",
"DROP",
"ELSE",
82 "EXCLUSIVE",
"EXISTS",
"FILE",
"FLOAT",
"FOR",
"FROM",
"GRANT",
"GROUP",
83 "HAVING",
"IDENTIFIED",
"IMMEDIATE",
"IN",
"INCREMENT",
"INDEX",
"INITIAL",
84 "INSERT",
"INTEGER",
"INTERSECT",
"INTO",
"IS",
"LEVEL",
"LIKE",
"LOCK",
"LONG",
85 "MAXEXTENTS",
"MINUS",
"MLSLABEL",
"MODE",
"MODIFY",
"NOAUDIT",
"NOCOMPRESS",
"NOT",
86 "NOWAIT",
"NULL",
"NUMBER",
"OF",
"OFFLINE",
"ON",
"ONLINE",
"OPTION",
87 "OR",
"ORDER",
"PCTFREE",
"PRIOR",
"PRIVILEGES",
"PUBLIC",
"RAW",
"RENAME",
88 "RESOURCE",
"REVOKE",
"ROW",
"ROWID",
"ROWNUM",
"ROWS",
"SELECT",
"SESSION",
"SET",
89 "SHARE",
"SIZE",
"SMALLINT",
"START",
"SUCCESSFUL",
"SYNONYM",
"SYSDATE",
"TABLE",
90 "THEN",
"TO",
"TRIGGER",
"UID",
"UNION",
"UNIQUE",
"UPDATE",
"USER",
"VALIDATE",
91 "VALUES",
"VARCHAR",
"VARCHAR2",
"VIEW",
"WHENEVER",
"WHERE",
"WITH"
101 array(
"use_transactions" =>
true));
109 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] =
'utf8';
110 $this->
query(
"ALTER SESSION SET nls_length_semantics='CHAR'");
111 $this->
query(
"ALTER SESSION SET NLS_SORT = binary_ci");
131 return "LOCALTIMESTAMP";
141 return "TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
142 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND')";
146 return "to_char(TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
147 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND'), 'yyyy-mm-dd hh24:mi:ss')";
158 return "ROUND((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400))";
166 return $a_table.
"_".$a_constraint;
192 function replace($a_table, $a_pk_columns, $a_other_columns)
194 $a_columns = array_merge($a_pk_columns, $a_other_columns);
196 $field_values = array();
197 $placeholders = array();
202 $val_field = array();
205 foreach ($a_columns as $k => $col)
207 if($col[0] ==
'clob' or $col[0] ==
'blob')
209 $val_field[] = $this->
quote($col[1],
'text').
" ".$k;
213 $val_field[] = $this->
quote($col[1], $col[0]).
" ".$k;
216 $placeholders[] =
"%s";
217 $placeholders2[] =
":$k";
220 $field_values[$k] = $col[1];
221 if ($col[0] ==
"blob" || $col[0] ==
"clob")
232 foreach ($a_pk_columns as $k => $col)
234 $abpk[] =
"a.".$k.
" = b.".$k;
235 $delwhere[] = $k.
" = ".$this->
quote($col[1], $col[0]);
237 foreach ($a_other_columns as $k => $col)
239 $aboc[] =
"a.".$k.
" = b.".$k;
243 $this->
manipulate(
"DELETE FROM ".$a_table.
" WHERE ".
244 implode ($delwhere,
" AND ")
246 $this->
insert($a_table, $a_columns);
249 $this->
handleError($r,
"replace, delete/insert(".$a_table.
")");
253 $q =
"MERGE INTO ".$a_table.
" a ".
254 "USING (SELECT ".implode($val_field,
", ").
" ".
255 "FROM DUAL) b ON (".implode($abpk,
" AND ").
") ".
256 "WHEN MATCHED THEN UPDATE SET ".implode($aboc,
", ").
" ".
257 "WHEN NOT MATCHED THEN INSERT (".implode($a,
",").
") VALUES (".implode($b,
",").
")";
270 public function locate($a_needle,$a_string,$a_start_pos = 1)
272 $locate =
' INSTR( ';
273 $locate .= (
'SUBSTR('.$a_string.
',0,'.self::CLOB_BUFFER_SIZE.
')');
275 $locate .= $a_needle;
277 $locate .= $a_start_pos;
293 public function like($a_col, $a_type, $a_value =
"?", $case_insensitive =
true)
295 if($a_type ==
'text')
297 return parent::like($a_col,$a_type,$a_value,$case_insensitive);
300 if (!in_array($a_type, array(
"text",
"clob",
"blob")))
302 $this->
raisePearError(
"Like: Invalid column type '".$a_type.
"'.", $this->error_class->FATAL);
306 if ($case_insensitive)
308 return "UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(?))";
312 return "SUBSTR(".$a_col .
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(?)";
317 if ($case_insensitive)
319 return " UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(".$this->
quote($a_value,
'text').
"))";
323 return " SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(".$this->
quote($a_value,
'text').
")";
334 public function concat($a_values, $a_allow_null =
true)
336 if(count($a_values) <= 2)
342 foreach($a_values as $field_info)
348 array($concat_value,$concat_type),
349 array($field_info[0],$field_info[1])),
356 $concat_value = $field_info[0];
357 $concat_type = $field_info[1];
360 return $concat_value;
377 function in($a_field, $a_values, $negate =
false, $a_type =
"")
379 if(count($a_values) <= self::LIMIT_EXPRESSIONS_IN_LIST)
381 return parent::in($a_field,$a_values,$negate,$a_type);
385 $concat = $negate ?
' AND ' :
' OR ';
396 $spliced = array_splice($a_values, 0, self::LIMIT_EXPRESSIONS_IN_LIST);
422 foreach($a_tables as $table)
424 $lock =
'LOCK TABLE ';
426 $lock .= ($table[
'name'].
' ');
428 switch($table[
'type'])
431 $lock .=
' IN SHARE MODE ';
435 $lock .=
' IN EXCLUSIVE MODE ';
443 $this->db->beginTransaction();
444 foreach($locks as $lock)
446 $this->db->query($lock);
447 $ilLog->write(__METHOD__.
': '.$lock);
471 $query =
"ALTER TABLE ".$a_table.
" DROP PRIMARY KEY DROP INDEX";