5 include_once (
"./Services/Database/classes/MDB2/class.ilDB.php");
36 if(!isset(
$GLOBALS[
'_MDB2_dsninfo_default'][
'charset'])
or 37 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] !=
'utf8')
39 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] =
'utf8';
42 return array(
'phptype' =>
'oci8',
64 $query =
'SELECT * FROM v$version';
69 return parent::getDBVersion();
72 return isset(
$row[
'banner']) ?
$row[
'banner'] : parent::getDBVersion();
83 "ACCESS",
"ADD",
"ALL",
"ALTER",
"AND",
"ANY",
"AS",
"ASC",
84 "AUDIT",
"BETWEEN",
"BY",
"CHAR",
"CHECK",
"CLUSTER",
"COLUMN",
85 "COMMENT",
"COMPRESS",
"CONNECT",
"CREATE",
"CURRENT",
"DATE",
86 "DECIMAL",
"DEFAULT",
"DELETE",
"DESC",
"DISTINCT",
"DROP",
"ELSE",
87 "EXCLUSIVE",
"EXISTS",
"FILE",
"FLOAT",
"FOR",
"FROM",
"GRANT",
"GROUP",
88 "HAVING",
"IDENTIFIED",
"IMMEDIATE",
"IN",
"INCREMENT",
"INDEX",
"INITIAL",
89 "INSERT",
"INTEGER",
"INTERSECT",
"INTO",
"IS",
"LEVEL",
"LIKE",
"LOCK",
"LONG",
90 "MAXEXTENTS",
"MINUS",
"MLSLABEL",
"MODE",
"MODIFY",
"NOAUDIT",
"NOCOMPRESS",
"NOT",
91 "NOWAIT",
"NULL",
"NUMBER",
"OF",
"OFFLINE",
"ON",
"ONLINE",
"OPTION",
92 "OR",
"ORDER",
"PCTFREE",
"PRIOR",
"PRIVILEGES",
"PUBLIC",
"RAW",
"RENAME",
93 "RESOURCE",
"REVOKE",
"ROW",
"ROWID",
"ROWNUM",
"ROWS",
"SELECT",
"SESSION",
"SET",
94 "SHARE",
"SIZE",
"SMALLINT",
"START",
"SUCCESSFUL",
"SYNONYM",
"SYSDATE",
"TABLE",
95 "THEN",
"TO",
"TRIGGER",
"UID",
"UNION",
"UNIQUE",
"UPDATE",
"USER",
"VALIDATE",
96 "VALUES",
"VARCHAR",
"VARCHAR2",
"VIEW",
"WHENEVER",
"WHERE",
"WITH" 106 array(
"use_transactions" =>
true));
114 $GLOBALS[
'_MDB2_dsninfo_default'][
'charset'] =
'utf8';
115 $this->
query(
"ALTER SESSION SET nls_length_semantics='CHAR'");
116 $this->
query(
"ALTER SESSION SET NLS_SORT = binary_ci");
136 return "LOCALTIMESTAMP";
146 return "TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
147 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND')";
151 return "to_char(TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
152 "+ NUMTODSINTERVAL(".$a_expr.
", 'SECOND'), 'yyyy-mm-dd hh24:mi:ss')";
163 return "ROUND((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400))";
171 return $a_table.
"_".$a_constraint;
197 function replace($a_table, $a_pk_columns, $a_other_columns)
199 $a_columns = array_merge($a_pk_columns, $a_other_columns);
201 $field_values =
array();
202 $placeholders =
array();
207 $val_field =
array();
210 foreach ($a_columns as $k => $col)
212 if($col[0] ==
'clob' or $col[0] ==
'blob')
214 $val_field[] = $this->
quote($col[1],
'text').
" ".$k;
218 $val_field[] = $this->
quote($col[1], $col[0]).
" ".$k;
221 $placeholders[] =
"%s";
222 $placeholders2[] =
":$k";
226 if ($col[0] ==
'integer' && !is_null($col[1]))
228 $col[1] = (int) $col[1];
232 $field_values[$k] = $col[1];
233 if ($col[0] ==
"blob" || $col[0] ==
"clob")
244 foreach ($a_pk_columns as $k => $col)
246 $abpk[] =
"a.".$k.
" = b.".$k;
247 $delwhere[] = $k.
" = ".$this->
quote($col[1], $col[0]);
249 foreach ($a_other_columns as $k => $col)
251 $aboc[] =
"a.".$k.
" = b.".$k;
255 $this->
manipulate(
"DELETE FROM ".$a_table.
" WHERE ".
256 implode ($delwhere,
" AND ")
258 $this->
insert($a_table, $a_columns);
261 $this->
handleError(
$r,
"replace, delete/insert(".$a_table.
")");
265 $q =
"MERGE INTO ".$a_table.
" a ".
266 "USING (SELECT ".implode($val_field,
", ").
" ".
267 "FROM DUAL) b ON (".implode($abpk,
" AND ").
") ".
268 "WHEN MATCHED THEN UPDATE SET ".implode($aboc,
", ").
" ".
269 "WHEN NOT MATCHED THEN INSERT (".implode($a,
",").
") VALUES (".implode($b,
",").
")";
282 public function locate($a_needle,$a_string,$a_start_pos = 1)
284 $locate =
' INSTR( ';
285 $locate .= (
'SUBSTR('.$a_string.
',0,'.self::CLOB_BUFFER_SIZE.
')');
287 $locate .= $a_needle;
289 $locate .= $a_start_pos;
305 public function like($a_col,
$a_type, $a_value =
"?", $case_insensitive =
true)
309 return parent::like($a_col,
$a_type,$a_value,$case_insensitive);
318 if ($case_insensitive)
320 return "UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(?))";
324 return "SUBSTR(".$a_col .
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(?)";
329 if ($case_insensitive)
331 return " UPPER(SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
")) LIKE(UPPER(".$this->
quote($a_value,
'text').
"))";
335 return " SUBSTR(".$a_col.
",0,".self::CLOB_BUFFER_SIZE.
") LIKE(".$this->
quote($a_value,
'text').
")";
348 if(count($a_values) <= 2)
350 return parent::concat($a_values,
false);
354 foreach($a_values as $field_info)
358 $concat_value = parent::concat(
360 array($concat_value,$concat_type),
361 array($field_info[0],$field_info[1])),
368 $concat_value = $field_info[0];
369 $concat_type = $field_info[1];
372 return $concat_value;
389 function in($a_field, $a_values, $negate =
false,
$a_type =
"")
391 if(count($a_values) <= self::LIMIT_EXPRESSIONS_IN_LIST)
393 return parent::in($a_field,$a_values,$negate,
$a_type);
397 $concat = $negate ?
' AND ' :
' OR ';
408 $spliced = array_splice($a_values, 0, self::LIMIT_EXPRESSIONS_IN_LIST);
409 $in .= parent::in($a_field, $spliced, $negate,
$a_type);
435 foreach($a_tables as $table)
437 $lock =
'LOCK TABLE ';
439 $lock .= ($table[
'name'].
' ');
441 switch($table[
'type'])
444 $lock .=
' IN SHARE MODE ';
448 $lock .=
' IN EXCLUSIVE MODE ';
456 $this->db->beginTransaction();
457 foreach($locks as $lock)
459 $this->db->query($lock);
460 $ilLog->write(__METHOD__.
': '.$lock);
485 $query =
"ALTER TABLE ".$a_table.
" DROP PRIMARY KEY DROP INDEX";
493 unset($storage_engine);
raisePearError($a_message, $a_level="")
Raise an error.
getPrimaryKeyIdentifier()
Primary key identifier.
isError($data, $code=null)
Tell whether a value is a MDB2 error.
query($sql, $a_handle_error=true)
Query.
doConnect()
Standard way to connect to db.
unlockTables()
Unlock tables.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
dropPrimaryKey($a_table)
Drop a primary key from a table.
getDBPort()
Get database port.
setStorageEngine($storage_engine)
unixTimestamp()
Unix timestamp.
constraintName($a_table, $a_constraint)
Constraint names must be "globally" unique in oracle.
getDBName()
Get database name.
quote($a_query, $a_type=null)
Wrapper for quote method.
lockTables($a_tables)
Lock table.
getDBHost()
Get database host.
getDBUser()
Get database user.
& connect($dsn, $options=false)
Create a new MDB2 connection object and connect to the specified database.
like($a_col, $a_type, $a_value="?", $case_insensitive=true)
Provisional LIKE support for oracle CLOB's Uses SUBSTR to reduce the length.
const LIMIT_EXPRESSIONS_IN_LIST
handleError($a_res, $a_info="", $a_level="")
Handle MDB2 Errors.
insert($a_table, $a_columns)
Convenient method for standard insert statements, example field array:
initConnection()
Initialize the database connection.
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
manipulate($sql)
Data manipulation.
dropFulltextIndex($a_table, $a_name)
replace($a_table, $a_pk_columns, $a_other_columns)
Replace into method.
supportsFulltext()
Is fulltext index supported?
concat(array $a_values, $a_allow_null=true)
CONCAT for oracle allows only the concatenation of two values.
fromUnixtime($a_expr, $a_to_text=true)
fromUnixtime (makes timestamp out of unix timestamp)
getDBPassword()
Get database password.
static getReservedWords()
Get reserved words.
in($a_field, $a_values, $negate=false, $a_type="")
Overwritten implementation of $ilDB->in to avoid ORA-01795 (maximum number of expressions in a list i...
locate($a_needle, $a_string, $a_start_pos=1)
Create locate string.