ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDBOracle Class Reference

Oracle Database Wrapper. More...

+ Inheritance diagram for ilDBOracle:
+ Collaboration diagram for ilDBOracle:

Public Member Functions

 loadModule ($module)
 
 getDSN ()
 Get DSN. More...
 
 getDBType ()
 Get DB Type. More...
 
 getDBVersion ()
 
 doConnect ()
 Standard way to connect to db. More...
 
 initConnection ()
 Initialize the database connection. More...
 
 now ()
 now() More...
 
 fromUnixtime ($a_expr, $a_to_text=true)
 fromUnixtime (makes timestamp out of unix timestamp) More...
 
 unixTimestamp ()
 Unix timestamp. More...
 
 constraintName ($a_table, $a_constraint)
 Constraint names must be "globally" unique in oracle. More...
 
 getPrimaryKeyIdentifier ()
 Primary key identifier. More...
 
 supportsFulltext ()
 Is fulltext index supported? More...
 
 replace ($a_table, $a_pk_columns, $a_other_columns)
 Replace into method. More...
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 Create locate string. More...
 
 like ($a_col, $a_type, $a_value="?", $case_insensitive=true)
 Provisional LIKE support for oracle CLOB's Uses SUBSTR to reduce the length. More...
 
 concat (array $a_values, $a_allow_null=true)
 CONCAT for oracle allows only the concatenation of two values. More...
 
 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 is 1000) More...
 
 lockTables ($a_tables)
 Lock table. More...
 
 unlockTables ()
 Unlock tables. More...
 
 dropPrimaryKey ($a_table)
 Drop a primary key from a table. More...
 
 setStorageEngine ($storage_engine)
 
 getStorageEngine ()
 
 dropFulltextIndex ($a_table, $a_name)
 
- Public Member Functions inherited from ilDB
 setDBUser ($a_user)
 Set database user. More...
 
 getDBUser ()
 Get database user. More...
 
 setDBPort ($a_port)
 Set database port. More...
 
 getDBPort ()
 Get database port. More...
 
 setDBHost ($a_host)
 Set database host. More...
 
 getDBHost ()
 Get database host. More...
 
 setDBPassword ($a_password)
 Set database password. More...
 
 getDBPassword ()
 Get database password. More...
 
 setDBName ($a_name)
 Set database name. More...
 
 getDBName ()
 Get database name. More...
 
 getDSN ()
 Get DSN. More...
 
 getDBVersion ()
 Get DB version. More...
 
 getDBType ()
 Get DSN. More...
 
 enableResultBuffering ($a_status)
 En/disable result buffering. More...
 
 initFromIniFile ($tmpClientIniFile=null)
 Init db parameters from ini file. More...
 
 connect ($a_return_false_for_error=false)
 Open the connection. More...
 
 doConnect ()
 Standard way to connect to db. More...
 
 disconnect ()
 Disconnect. More...
 
 getHostDSN ()
 Should return a valid value, if host connections are possible (connectHost) to create a new database from scratch. More...
 
 connectHost ()
 Sets up a host connection only (no specific database used). More...
 
 supportsFulltext ()
 
 supportsSlave ()
 Supports slave. More...
 
 supports ($feature)
 
 supportsTransactions ()
 
 useSlave ($a_val=true)
 Use slave. More...
 
 handleError ($a_res, $a_info="", $a_level="")
 Handle MDB2 Errors. More...
 
 raisePearError ($a_message, $a_level="")
 Raise an error. More...
 
 createDatabase ($a_name, $a_charset="utf8", $a_collation="")
 Create database. More...
 
 createTable ($a_name, $a_definition_array, $a_drop_table=false, $a_ignore_erros=false)
 Create a new table in the database. More...
 
 dropTable ($a_name, $a_error_if_not_existing=true)
 Drop a table. More...
 
 alterTable ($a_name, $a_changes)
 Alter a table in the database This method is DEPRECATED, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu PLEASE USE THE SPECIALIZED METHODS OF THIS CLASS TO CHANGE THE DB SCHEMA. More...
 
 addTableColumn ($a_table, $a_column, $a_attributes)
 Add table column Use this only on aleady "abstracted" tables. More...
 
 dropTableColumn ($a_table, $a_column)
 Drop table column Use this only on aleady "abstracted" tables. More...
 
 modifyTableColumn ($a_table, $a_column, $a_attributes)
 Modify a table column Use this only on aleady "abstracted" tables. More...
 
 renameTableColumn ($a_table, $a_column, $a_new_column)
 Rename a table column Use this only on aleady "abstracted" tables. More...
 
 renameTable ($a_name, $a_new_name)
 Rename a table. More...
 
 addPrimaryKey ($a_table, $a_fields)
 Add a primary key to a table. More...
 
 getPrimaryKeyIdentifier ()
 Primary key identifier. More...
 
 dropPrimaryKey ($a_table)
 Drop a primary key from a table. More...
 
 addFulltextIndex ($a_table, $a_fields, $a_name="in")
 Add fulltext index. More...
 
 isFulltextIndex ($a_table, $a_name)
 Is index a fulltext index? More...
 
 indexExistsByFields ($a_table, $a_fields)
 Check if index exists. More...
 
 dropIndexByFields ($a_table, $a_fields)
 Drop index by field(s) More...
 
 dropIndex ($a_table, $a_name="in")
 Drop an index from a table. More...
 
 addUniqueConstraint ($a_table, $a_fields, $a_name="con")
 Add a unique constraint to a table. More...
 
 dropUniqueConstraint ($a_table, $a_name="con")
 Drop a constraint from a table. More...
 
 dropUniqueConstraintByFields ($a_table, $a_fields)
 Drop constraint by field(s) More...
 
 createSequence ($a_table_name, $a_start=1)
 Create a sequence for a table. More...
 
 dropSequence ($a_table_name)
 Drop a sequence for a table. More...
 
 checkTableName ($a_name)
 Check whether a table name is valid. More...
 
 checkTableColumns ($a_cols)
 Check table columns definition. More...
 
 checkColumn ($a_col, $a_def)
 Check column definition. More...
 
 checkColumnDefinition ($a_def, $a_modify_mode=false)
 Check whether a column definition is valid. More...
 
 checkColumnName ($a_name)
 Check whether a column name is valid. More...
 
 checkIndexName ($a_name)
 Check whether an index name is valid. More...
 
 getAllowedAttributes ()
 
 constraintName ($a_table, $a_constraint)
 Determine contraint name by table name and constraint name. More...
 
 query ($sql, $a_handle_error=true)
 Query. More...
 
 queryF ($a_query, $a_types, $a_values)
 Formatted query (for SELECTS). More...
 
 manipulateF ($a_query, $a_types, $a_values)
 Formatted manupulate (for DELETE, UPDATE, INSERT). More...
 
 logStatement ($sql)
 Helper function, should usually not be called. More...
 
 setLimit ($a_limit, $a_offset=0)
 Set limit and offset for a query. More...
 
 nextId ($a_table_name)
 Get next ID for an index. More...
 
 manipulate ($sql)
 Data manipulation. More...
 
 prepare ($a_query, $a_types=null, $a_result_types=null)
 Prepare a query (SELECT) statement to be used with execute. More...
 
 prepareManip ($a_query, $a_types=null)
 Prepare a data manipulation statement to be used with execute. More...
 
 execute ($a_stmt, $a_data=null)
 Execute a query statement prepared by either prepare() or prepareManip() More...
 
 executeMultiple ($a_stmt, $a_data)
 Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays. More...
 
 insert ($a_table, $a_columns)
 Convenient method for standard insert statements, example field array: More...
 
 update ($a_table, $a_columns, $a_where)
 Convenient method for standard update statements, example field array: More...
 
 replace ($a_table, $a_pk_columns, $a_other_columns)
 Replace into method. More...
 
 fetchAssoc ($a_set)
 Fetch row as associative array from result set. More...
 
 free ($a_st)
 Free a statement / result set. More...
 
 fetchObject ($a_set)
 Fetch row as object from result set. More...
 
 numRows ($a_set)
 Fetch row as associative array from result set. More...
 
 in ($a_field, $a_values, $negate=false, $a_type="")
 Get abstract in-clause for given array. More...
 
 addTypesToArray ($a_arr, $a_type, $a_cnt)
 Adds a type x times to an array. More...
 
 now ()
 now() More...
 
 concat (array $a_values, $a_allow_null=true)
 Abstraction of SQL function CONCAT. More...
 
 substr ($a_exp, $a_pos=1, $a_len=-1)
 Substring. More...
 
 upper ($a_exp)
 Upper. More...
 
 lower ($a_exp)
 Upper. More...
 
 locate ($a_needle, $a_string, $a_start_pos=1)
 Create locate string. More...
 
 like ($a_col, $a_type, $a_value="?", $case_insensitive=true)
 Like. More...
 
 equals ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields. More...
 
 equalsNot ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields. More...
 
 fromUnixtime ($a_expr, $a_to_text=true)
 fromUnixtime (makes timestamp out of unix timestamp) More...
 
 unixTimestamp ()
 Unix timestamp. More...
 
 tableExists ($a_table)
 Check, whether a given table exists. More...
 
 tableColumnExists ($a_table, $a_column_name)
 Checks for the existence of a table column. More...
 
 uniqueConstraintExists ($a_table, array $a_fields)
 Checks if a unique constraint exists based on the fields of the unique constraint (not the name) More...
 
 listTables ()
 Get all tables. More...
 
 sequenceExists ($a_sequence)
 Check, whether a given sequence exists. More...
 
 listSequences ()
 Get all sequences. More...
 
 quote ($a_query, $a_type=null)
 Wrapper for quote method. More...
 
 quoteIdentifier ($a_identifier, $check_option=false)
 Quote table and field names. More...
 
 beginTransaction ()
 Begin Transaction. More...
 
 commit ()
 Commit a transaction. More...
 
 rollback ()
 Rollback a transaction. More...
 
 lockTables ($a_tables)
 Abstraction of lock table. More...
 
 unlockTables ()
 Unlock tables locked by previous lock table calls. More...
 
 autoExecute ($a_tablename, $a_fields, $a_mode=MDB2_AUTOQUERY_INSERT, $a_where=false)
 Wrapper for Pear autoExecute. More...
 
 getLastInsertId ()
 Get last insert id. More...
 
 getOne ($sql)
 getOne. More...
 
 getRow ($sql, $mode=ilDBConstants::FETCHMODE_OBJECT)
 getRow. More...
 
 setSubType ($a_value)
 Set sub type. More...
 
 getSubType ()
 Get sub type. More...
 
 migrateAllTablesToEngine ($engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 supportsEngineMigration ()
 
 getSequenceName ($table_name)
 
 buildAtomQuery ()
 
 sanitizeMB4StringIfNotSupported ($query)
 
Parameters
$querystring to sanitize, all MB4-Characters like emojis will re replaced with ???
Returns
string sanitized query
More...
 
 doesCollationSupportMB4Strings ()
 
 cast ($a_field_name, $a_dest_type)
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 
- Public Member Functions inherited from ilDBInterface
 query ($query)
 
 fetchAll ($query_result, $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
 
 addIndex ($table_name, $fields, $index_name='', $fulltext=false)
 
 substr ($a_exp)
 
 groupConcat ($a_field_name, $a_seperator=",", $a_order=NULL)
 

Static Public Member Functions

static getReservedWords ()
 Get reserved words. More...
 
- Static Public Member Functions inherited from ilDB
static getReservedWords ()
 Get reserved words. More...
 
static isDbError ($a_res)
 Check error. More...
 
static isReservedWord ($a_word)
 Checks whether a word is a reserved word in one of the supported databases. More...
 
- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 

Data Fields

const CLOB_BUFFER_SIZE = 2000
 
const LIMIT_EXPRESSIONS_IN_LIST = 1000
 
- Data Fields inherited from ilDB
const LOCK_WRITE = 1
 
const LOCK_READ = 2
 
 $error_class
 
 $db
 
 $result
 
 $allowed_attributes
 
 $sub_type
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Additional Inherited Members

- Protected Member Functions inherited from ilDB
 initConnection ()
 Initialize the database connection. More...
 
 initHostConnection ()
 Initialize the host connection (no specific database) More...
 
 loadMDB2Extensions ()
 load additional mdb2 extensions and set their constants More...
 
 getCreateTableOptions ()
 Get options for the create table statement. More...
 

Detailed Description

Oracle Database Wrapper.

This class extends the main ILIAS database wrapper ilDB. Only a few methods should be overwritten, that contain Oracle specific statements and methods.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id
class.ilDB.php 18989 2009-02-15 12:57:19Z akill

Definition at line 18 of file class.ilDBOracle.php.

Member Function Documentation

◆ concat()

ilDBOracle::concat ( array  $a_values,
  $a_allow_null = true 
)

CONCAT for oracle allows only the concatenation of two values.

Parameters
object$a_values
object$a_allow_null[optional]
Returns

Implements ilDBInterface.

Definition at line 346 of file class.ilDBOracle.php.

References array.

347  {
348  if(count($a_values) <= 2)
349  {
350  return parent::concat($a_values,false);
351  }
352 
353  $first = true;
354  foreach($a_values as $field_info)
355  {
356  if(!$first)
357  {
358  $concat_value = parent::concat(
359  array(
360  array($concat_value,$concat_type),
361  array($field_info[0],$field_info[1])),
362  false
363  );
364  }
365  else
366  {
367  $first = false;
368  $concat_value = $field_info[0];
369  $concat_type = $field_info[1];
370  }
371  }
372  return $concat_value;
373  }
Create styles array
The data for the language used.

◆ constraintName()

ilDBOracle::constraintName (   $a_table,
  $a_constraint 
)

Constraint names must be "globally" unique in oracle.

Implements ilDBInterface.

Definition at line 169 of file class.ilDBOracle.php.

170  {
171  return $a_table."_".$a_constraint;
172  }

◆ doConnect()

ilDBOracle::doConnect ( )

Standard way to connect to db.

Definition at line 103 of file class.ilDBOracle.php.

References array, MDB2\connect(), and getDSN().

104  {
105  $this->db = MDB2::connect($this->getDSN(),
106  array("use_transactions" => true));
107  }
& connect($dsn, $options=false)
Create a new MDB2 connection object and connect to the specified database.
Definition: MDB2.php:436
Create styles array
The data for the language used.
getDSN()
Get DSN.
+ Here is the call graph for this function:

◆ dropFulltextIndex()

ilDBOracle::dropFulltextIndex (   $a_table,
  $a_name 
)
Parameters
$a_table
$a_name
Returns
bool

Implements ilDBInterface.

Definition at line 502 of file class.ilDBOracle.php.

502  {
503  return false;
504  }

◆ dropPrimaryKey()

ilDBOracle::dropPrimaryKey (   $a_table)

Drop a primary key from a table.

Parameters
stringtable name

Definition at line 480 of file class.ilDBOracle.php.

References $query, $res, and ilDB\handleError().

481  {
482  // oracle 10: dropping constraint may not drop attached index
483  // http://www.orafaq.com/forum/t/59807/0/
484 
485  $query = "ALTER TABLE ".$a_table." DROP PRIMARY KEY DROP INDEX";
486  $res = $this->db->query($query);
487 
488  return $this->handleError($res, "dropPrimaryKey(".$a_table.")");
489  }
handleError($a_res, $a_info="", $a_level="")
Handle MDB2 Errors.
Definition: class.ilDB.php:423
+ Here is the call graph for this function:

◆ fromUnixtime()

ilDBOracle::fromUnixtime (   $a_expr,
  $a_to_text = true 
)

fromUnixtime (makes timestamp out of unix timestamp)

Definition at line 142 of file class.ilDBOracle.php.

143  {
144  if (!$a_to_text)
145  {
146  return "TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
147  "+ NUMTODSINTERVAL(".$a_expr.", 'SECOND')";
148  }
149  else
150  {
151  return "to_char(TO_DATE('19700101000000','YYYYMMDDHH24MISS') ".
152  "+ NUMTODSINTERVAL(".$a_expr.", 'SECOND'), 'yyyy-mm-dd hh24:mi:ss')";
153  }
154  }

◆ getDBType()

ilDBOracle::getDBType ( )

Get DB Type.

Implements ilDBInterface.

Definition at line 57 of file class.ilDBOracle.php.

58  {
59  return "oracle";
60  }

◆ getDBVersion()

ilDBOracle::getDBVersion ( )

Definition at line 62 of file class.ilDBOracle.php.

References $query, $res, $row, ilDBConstants\FETCHMODE_ASSOC, and MDB2\isError().

63  {
64  $query = 'SELECT * FROM v$version';
65  $res = $this->db->query($query);
66 
67  if(MDB2::isError($res))
68  {
69  return parent::getDBVersion();
70  }
72  return isset($row['banner']) ? $row['banner'] : parent::getDBVersion();
73  }
isError($data, $code=null)
Tell whether a value is a MDB2 error.
Definition: MDB2.php:599
+ Here is the call graph for this function:

◆ getDSN()

ilDBOracle::getDSN ( )

Get DSN.

Implements ilDBInterface.

Definition at line 32 of file class.ilDBOracle.php.

References $GLOBALS, array, ilDB\getDBHost(), ilDB\getDBName(), ilDB\getDBPassword(), ilDB\getDBPort(), and ilDB\getDBUser().

Referenced by doConnect().

33  {
34  // TODO: check if there is another solution.
35  // This works with 11g
36  if(!isset($GLOBALS['_MDB2_dsninfo_default']['charset']) or
37  $GLOBALS['_MDB2_dsninfo_default']['charset'] != 'utf8')
38  {
39  $GLOBALS['_MDB2_dsninfo_default']['charset'] = 'utf8';
40  }
41 
42  return array('phptype' => 'oci8',
43  'hostspec' => $this->getDBHost(),
44  'username' => $this->getDBUser(),
45  'password' => $this->getDBPassword(),
46  'port' => $this->getDBPort(),
47  'service' => $this->getDBName()
48  );
49 
50  //return "oci8://".$this->getDBUser().":".$this->getDBPassword()."@".
51  // $this->getDBHost()."/?service=".$this->getDBName();
52  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getDBPort()
Get database port.
Definition: class.ilDB.php:103
getDBName()
Get database name.
Definition: class.ilDB.php:163
getDBHost()
Get database host.
Definition: class.ilDB.php:123
getDBUser()
Get database user.
Definition: class.ilDB.php:83
Create styles array
The data for the language used.
getDBPassword()
Get database password.
Definition: class.ilDB.php:143
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrimaryKeyIdentifier()

ilDBOracle::getPrimaryKeyIdentifier ( )

Primary key identifier.

Implements ilDBInterface.

Definition at line 177 of file class.ilDBOracle.php.

178  {
179  return "pk";
180  }

◆ getReservedWords()

static ilDBOracle::getReservedWords ( )
static

Get reserved words.

Implements ilDBInterface.

Definition at line 78 of file class.ilDBOracle.php.

References array.

79  {
80  // version: 10g
81  // url: http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/ap_keywd.htm#g691972
82  return array(
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"
97  );
98  }
Create styles array
The data for the language used.

◆ getStorageEngine()

ilDBOracle::getStorageEngine ( )
Returns
string

Implements ilDBInterface.

Definition at line 497 of file class.ilDBOracle.php.

497  {
498  return null;
499  }

◆ in()

ilDBOracle::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 is 1000)

This implementation rewrites the in clause to field IN (1,2,3,...,1000) OR field IN (1000,1001,...,2000)

Example: $ids = array(10,12,18); $st = $ilDB->prepare("SELECT * FROM table ". "WHERE ".$ilDB->in("id", $ids), $ilDB->addTypesToArray($types, "integer", count($ids))); $set = $ilDB->execute($st, $ids);

Implements ilDBInterface.

Definition at line 389 of file class.ilDBOracle.php.

References $a_type, and $in.

390  {
391  if(count($a_values) <= self::LIMIT_EXPRESSIONS_IN_LIST)
392  {
393  return parent::in($a_field,$a_values,$negate,$a_type);
394  }
395 
396  $first = true;
397  $concat = $negate ? ' AND ' : ' OR ';
398  $in = '(';
399  do
400  {
401  if(!$first)
402  {
403  $in .= $concat;
404 
405  }
406  $first = false;
407 
408  $spliced = array_splice($a_values, 0, self::LIMIT_EXPRESSIONS_IN_LIST);
409  $in .= parent::in($a_field, $spliced, $negate, $a_type);
410 
411  }
412  while($a_values);
413 
414  return $in." ) ";
415  }
$a_type
Definition: workflow.php:93
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ initConnection()

ilDBOracle::initConnection ( )

Initialize the database connection.

Definition at line 112 of file class.ilDBOracle.php.

References $GLOBALS, and ilDB\query().

113  {
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");
117  }
query($sql, $a_handle_error=true)
Query.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

◆ like()

ilDBOracle::like (   $a_col,
  $a_type,
  $a_value = "?",
  $case_insensitive = true 
)

Provisional LIKE support for oracle CLOB's Uses SUBSTR to reduce the length.

TODO: we can use self::CLOB_BUFFER_SIZE = 4000 since since the maximum buffer is 4000 byte and not 4000 chars

Parameters
object$a_col
object$a_type
object$a_value[optional]
object$case_insensitive[optional]
Returns

Implements ilDBInterface.

Definition at line 305 of file class.ilDBOracle.php.

References $a_type, array, ilDB\quote(), and ilDB\raisePearError().

306  {
307  if($a_type == 'text')
308  {
309  return parent::like($a_col,$a_type,$a_value,$case_insensitive);
310  }
311 
312  if (!in_array($a_type, array("text", "clob", "blob")))
313  {
314  $this->raisePearError("Like: Invalid column type '".$a_type."'.", $this->error_class->FATAL);
315  }
316  if ($a_value == "?")
317  {
318  if ($case_insensitive)
319  {
320  return "UPPER(SUBSTR(".$a_col.",0,".self::CLOB_BUFFER_SIZE.")) LIKE(UPPER(?))";
321  }
322  else
323  {
324  return "SUBSTR(".$a_col .",0,".self::CLOB_BUFFER_SIZE.") LIKE(?)";
325  }
326  }
327  else
328  {
329  if ($case_insensitive)
330  {
331  return " UPPER(SUBSTR(".$a_col.",0,".self::CLOB_BUFFER_SIZE.")) LIKE(UPPER(".$this->quote($a_value, 'text')."))";
332  }
333  else
334  {
335  return " SUBSTR(".$a_col.",0,".self::CLOB_BUFFER_SIZE.") LIKE(".$this->quote($a_value, 'text').")";
336  }
337  }
338  }
raisePearError($a_message, $a_level="")
Raise an error.
Definition: class.ilDB.php:459
$a_type
Definition: workflow.php:93
quote($a_query, $a_type=null)
Wrapper for quote method.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ loadModule()

ilDBOracle::loadModule (   $module)
Parameters
$module
Returns
ilDBReverse|ilDBManager

Implements ilDBInterface.

Definition at line 24 of file class.ilDBOracle.php.

24  {
25  // TODO: Implement loadModule() method.
26  }

◆ locate()

ilDBOracle::locate (   $a_needle,
  $a_string,
  $a_start_pos = 1 
)

Create locate string.

Parameters
string$a_needle
string$a_string
int$a_start_pos[optional]
Returns

Implements ilDBInterface.

Definition at line 282 of file class.ilDBOracle.php.

283  {
284  $locate = ' INSTR( ';
285  $locate .= ('SUBSTR('.$a_string.',0,'.self::CLOB_BUFFER_SIZE.')');
286  $locate .= ',';
287  $locate .= $a_needle;
288  $locate .= ',';
289  $locate .= $a_start_pos;
290  $locate .= ') ';
291  return $locate;
292  }

◆ lockTables()

ilDBOracle::lockTables (   $a_tables)

Lock table.

E.g $ilDB->lockTable('tree',ilDBConstants::LOCK_WRITE,'t1')

Parameters
string$a_name
int$a_mode
string$a_alias
Deprecated:
Use ilAtomQuery instead
Returns

Implements ilDBInterface.

Definition at line 428 of file class.ilDBOracle.php.

References $counter, $ilLog, array, ilDBConstants\LOCK_READ, and ilDBConstants\LOCK_WRITE.

429  {
430  global $ilLog;
431 
432  $locks = array();
433 
434  $counter = 0;
435  foreach($a_tables as $table)
436  {
437  $lock = 'LOCK TABLE ';
438 
439  $lock .= ($table['name'].' ');
440 
441  switch($table['type'])
442  {
444  $lock .= ' IN SHARE MODE ';
445  break;
446 
448  $lock .= ' IN EXCLUSIVE MODE ';
449  break;
450  }
451 
452  $locks[] = $lock;
453  }
454 
455  // @TODO use and store a unique identifier to allow nested lock/unlocks
456  $this->db->beginTransaction();
457  foreach($locks as $lock)
458  {
459  $this->db->query($lock);
460  $ilLog->write(__METHOD__.': '.$lock);
461  }
462  return true;
463  }
$counter
Create styles array
The data for the language used.

◆ now()

ilDBOracle::now ( )

now()

Todo:
fix this

Implements ilDBInterface.

Definition at line 134 of file class.ilDBOracle.php.

135  {
136  return "LOCALTIMESTAMP";
137  }

◆ replace()

ilDBOracle::replace (   $a_table,
  $a_pk_columns,
  $a_other_columns 
)

Replace into method.

Parameters
stringtable name
arrayprimary key values: array("field1" => array("text", $name), "field2" => ...)
arrayother values: array("field1" => array("text", $name), "field2" => ...)

Implements ilDBInterface.

Definition at line 197 of file class.ilDBOracle.php.

References $r, array, ilDB\handleError(), ilDB\insert(), ilDB\manipulate(), and ilDB\quote().

198  {
199  $a_columns = array_merge($a_pk_columns, $a_other_columns);
200  $fields = array();
201  $field_values = array();
202  $placeholders = array();
203  $types = array();
204  $values = array();
205  $lobs = false;
206  $lob = array();
207  $val_field = array();
208  $a = array();
209  $b = array();
210  foreach ($a_columns as $k => $col)
211  {
212  if($col[0] == 'clob' or $col[0] == 'blob')
213  {
214  $val_field[] = $this->quote($col[1], 'text')." ".$k;
215  }
216  else
217  {
218  $val_field[] = $this->quote($col[1], $col[0])." ".$k;
219  }
220  $fields[] = $k;
221  $placeholders[] = "%s";
222  $placeholders2[] = ":$k";
223  $types[] = $col[0];
224 
225  // integer auto-typecast (this casts bool values to integer)
226  if ($col[0] == 'integer' && !is_null($col[1]))
227  {
228  $col[1] = (int) $col[1];
229  }
230 
231  $values[] = $col[1];
232  $field_values[$k] = $col[1];
233  if ($col[0] == "blob" || $col[0] == "clob")
234  {
235  $lobs = true;
236  $lob[$k] = $k;
237  }
238  $a[] = "a.".$k;
239  $b[] = "b.".$k;
240  }
241  $abpk = array();
242  $aboc = array();
243  $delwhere = array();
244  foreach ($a_pk_columns as $k => $col)
245  {
246  $abpk[] = "a.".$k." = b.".$k;
247  $delwhere[] = $k." = ".$this->quote($col[1], $col[0]);
248  }
249  foreach ($a_other_columns as $k => $col)
250  {
251  $aboc[] = "a.".$k." = b.".$k;
252  }
253  if ($lobs) // delete/insert
254  {
255  $this->manipulate("DELETE FROM ".$a_table." WHERE ".
256  implode ($delwhere, " AND ")
257  );
258  $this->insert($a_table, $a_columns);
259 
260  //$r = $this->db->extended->autoExecute($a_table, $field_values, MDB2_AUTOQUERY_INSERT, null, $types);
261  $this->handleError($r, "replace, delete/insert(".$a_table.")");
262  }
263  else // if no lobs are used, use manipulate
264  {
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, ",").")";
270  $r = $this->manipulate($q);
271  }
272  return $r;
273  }
quote($a_query, $a_type=null)
Wrapper for quote method.
$r
Definition: example_031.php:79
handleError($a_res, $a_info="", $a_level="")
Handle MDB2 Errors.
Definition: class.ilDB.php:423
insert($a_table, $a_columns)
Convenient method for standard insert statements, example field array:
Create styles array
The data for the language used.
manipulate($sql)
Data manipulation.
+ Here is the call graph for this function:

◆ setStorageEngine()

ilDBOracle::setStorageEngine (   $storage_engine)
Parameters
$storage_engine

Implements ilDBInterface.

Definition at line 492 of file class.ilDBOracle.php.

492  {
493  unset($storage_engine);
494  }

◆ supportsFulltext()

ilDBOracle::supportsFulltext ( )

Is fulltext index supported?

Implements ilDBInterface.

Definition at line 185 of file class.ilDBOracle.php.

186  {
187  return false;
188  }

◆ unixTimestamp()

ilDBOracle::unixTimestamp ( )

Unix timestamp.

Definition at line 159 of file class.ilDBOracle.php.

160  {
161  // sysdate should respect database time zone
162  // current_date would respect session time zone
163  return "ROUND((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400))";
164  }

◆ unlockTables()

ilDBOracle::unlockTables ( )

Unlock tables.

Deprecated:
Use ilAtomQuery instead
Returns

Implements ilDBInterface.

Definition at line 470 of file class.ilDBOracle.php.

471  {
472  $this->db->commit();
473  }

Field Documentation

◆ CLOB_BUFFER_SIZE

const ilDBOracle::CLOB_BUFFER_SIZE = 2000

Definition at line 20 of file class.ilDBOracle.php.

◆ LIMIT_EXPRESSIONS_IN_LIST

const ilDBOracle::LIMIT_EXPRESSIONS_IN_LIST = 1000

Definition at line 21 of file class.ilDBOracle.php.


The documentation for this class was generated from the following file: