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");
126 return "LOCALTIMESTAMP";
136 return "TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
137 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND')";
141 return "to_char(TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
142 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND'), 'yyyy-mm-dd hh24:mi:ss')";
153 return "ROUND((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400))";
161 return $a_table.
"_".$a_constraint;
187 function replace($a_table, $a_pk_columns, $a_other_columns)
189 $a_columns = array_merge($a_pk_columns, $a_other_columns);
191 $field_values = array();
192 $placeholders = array();
197 $val_field = array();
200 foreach ($a_columns as $k => $col)
202 if($col[0] ==
'clob' or $col[0] ==
'blob')
204 $val_field[] = $this->
quote($col[1],
'text').
" ".$k;
208 $val_field[] = $this->
quote($col[1], $col[0]).
" ".$k;
211 $placeholders[] =
"%s";
212 $placeholders2[] =
":$k";
215 $field_values[$k] = $col[1];
216 if ($col[0] ==
"blob" || $col[0] ==
"clob")
227 foreach ($a_pk_columns as $k => $col)
229 $abpk[] =
"a.".$k.
" = b.".$k;
230 $delwhere[] = $k.
" = ".$this->
quote($col[1], $col[0]);
232 foreach ($a_other_columns as $k => $col)
234 $aboc[] =
"a.".$k.
" = b.".$k;
238 $this->
manipulate(
"DELETE FROM ".$a_table.
" WHERE ".
239 implode ($delwhere,
" AND ")
241 $this->
insert($a_table, $a_columns);
244 $this->
handleError($r,
"replace, delete/insert(".$a_table.
")");
248 $q =
"MERGE INTO ".$a_table.
" a ".
249 "USING (SELECT ".implode($val_field,
", ").
" ".
250 "FROM DUAL) b ON (".implode($abpk,
" AND ").
") ".
251 "WHEN MATCHED THEN UPDATE SET ".implode($aboc,
", ").
" ".
252 "WHEN NOT MATCHED THEN INSERT (".implode($a,
",").
") VALUES (".implode($b,
",").
")";
265 public function locate($a_needle,$a_string,$a_start_pos = 1)
267 $locate =
' INSTR( ';
268 $locate .= (
'SUBSTR('.$a_string.
',0,'.self::CLOB_BUFFER_SIZE.
')');
270 $locate .= $a_needle;
272 $locate .= $a_start_pos;
288 public function like($a_col, $a_type, $a_value =
"?", $case_insensitive =
true)
290 if($a_type ==
'text')
292 return parent::like($a_col,$a_type,$a_value,$case_insensitive);
295 if (!in_array($a_type, array(
"text",
"clob",
"blob")))
297 $this->
raisePearError(
"Like: Invalid column type '".$a_type.
"'.", $this->error_class->FATAL);
301 if ($case_insensitive)
303 return "UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(?))";
307 return "SUBSTR(".$a_col .
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(?)";
312 if ($case_insensitive)
314 return " UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(".$this->
quote($a_value,
'text').
"))";
318 return " SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(".$this->
quote($a_value,
'text').
")";
329 public function concat($a_values, $a_allow_null =
true)
331 if(count($a_values) <= 2)
337 foreach($a_values as $field_info)
343 array($concat_value,$concat_type),
344 array($field_info[0],$field_info[1])),
351 $concat_value = $field_info[0];
352 $concat_type = $field_info[1];
355 return $concat_value;
372 function in($a_field, $a_values, $negate =
false, $a_type =
"")
374 if(count($a_values) <= self::LIMIT_EXPRESSIONS_IN_LIST)
376 return parent::in($a_field,$a_values,$negate,$a_type);
380 $concat = $negate ?
' AND ' :
' OR ';
391 $spliced = array_splice($a_values, 0, self::LIMIT_EXPRESSIONS_IN_LIST);
417 foreach($a_tables as $table)
419 $lock =
'LOCK TABLE ';
421 $lock .= ($table[
'name'].
' ');
423 switch($table[
'type'])
426 $lock .=
' IN SHARE MODE ';
430 $lock .=
' IN EXCLUSIVE MODE ';
438 $this->db->beginTransaction();
439 foreach($locks as $lock)
441 $this->db->query($lock);
442 $ilLog->write(__METHOD__.
': '.$lock);