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

Class arConnectorDB. More...

+ Inheritance diagram for arConnectorDB:
+ Collaboration diagram for arConnectorDB:

Public Member Functions

 checkConnection (ActiveRecord $ar)
 
 nextID (ActiveRecord $ar)
 
 installDatabase (ActiveRecord $ar, $fields)
 
 updateIndices (ActiveRecord $ar)
 
 updateDatabase (ActiveRecord $ar)
 
 resetDatabase (ActiveRecord $ar)
 
 truncateDatabase (ActiveRecord $ar)
 
 checkTableExists (ActiveRecord $ar)
 
 checkFieldExists (ActiveRecord $ar, $field_name)
 
 removeField (ActiveRecord $ar, $field_name)
 
 renameField (ActiveRecord $ar, $old_name, $new_name)
 
 create (ActiveRecord $ar)
 
 read (ActiveRecord $ar)
 
 update (ActiveRecord $ar)
 
 delete (ActiveRecord $ar)
 
 readSet (ActiveRecordList $arl)
 
 affectedRows (ActiveRecordList $arl)
 
 quote ($value, $type)
 
- Public Member Functions inherited from arConnector
 nextID (ActiveRecord $ar)
 
 checkConnection (ActiveRecord $ar)
 
 installDatabase (ActiveRecord $ar, $fields)
 
 updateDatabase (ActiveRecord $ar)
 
 resetDatabase (ActiveRecord $ar)
 
 truncateDatabase (ActiveRecord $ar)
 
 checkTableExists (ActiveRecord $ar)
 
 checkFieldExists (ActiveRecord $ar, $field_name)
 
 removeField (ActiveRecord $ar, $field_name)
 
 renameField (ActiveRecord $ar, $old_name, $new_name)
 
 create (ActiveRecord $ar)
 
 read (ActiveRecord $ar)
 
 update (ActiveRecord $ar)
 
 delete (ActiveRecord $ar)
 
 readSet (ActiveRecordList $arl)
 
 affectedRows (ActiveRecordList $arl)
 
 quote ($value, $type)
 
 updateIndices (ActiveRecord $ar)
 
 fixDate ($value)
 

Protected Member Functions

 returnDB ()
 

Detailed Description

Member Function Documentation

◆ affectedRows()

arConnectorDB::affectedRows ( ActiveRecordList  $arl)
Parameters
ActiveRecordList$arl
Returns
int

Definition at line 286 of file class.arConnectorDB.php.

References $ilDB, $tpl, ActiveRecordList\getArConcatCollection(), ActiveRecordList\getArSelectCollection(), returnDB(), ilUtil\sendInfo(), and ilDBConstants\TYPE_ORACLE.

286  {
287  $ilDB = $this->returnDB();
288  $q = self::buildQuery($arl);
289 
290  $set = $ilDB->query($q);
291 
292  return $ilDB->numRows($set);
293  }
global $ilDB
+ Here is the call graph for this function:

◆ checkConnection()

arConnectorDB::checkConnection ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
bool

Definition at line 29 of file class.arConnectorDB.php.

References returnDB().

29  {
30  return is_object($this->returnDB());
31  }
+ Here is the call graph for this function:

◆ checkFieldExists()

arConnectorDB::checkFieldExists ( ActiveRecord  $ar,
  $field_name 
)
Parameters
ActiveRecord$ar
$field_name
Returns
mixed

Definition at line 156 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getConnectorContainerName(), and returnDB().

156  {
157  $ilDB = $this->returnDB();
158 
159  return $ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name);
160  }
global $ilDB
+ Here is the call graph for this function:

◆ checkTableExists()

arConnectorDB::checkTableExists ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
mixed

: This is the proper ILIAS approach on how to do this BUT: This is exteremely slow (listTables is used)! However, this is not the place to fix this issue. Report.

Definition at line 139 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getConnectorContainerName(), and returnDB().

139  {
140  $ilDB = $this->returnDB();
141 
146  return $ilDB->tableExists($ar->getConnectorContainerName());
147  }
global $ilDB
+ Here is the call graph for this function:

◆ create()

arConnectorDB::create ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar

Definition at line 209 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getArrayForConnector(), ActiveRecord\getConnectorContainerName(), and returnDB().

209  {
210  $ilDB = $this->returnDB();
211  $ilDB->insert($ar->getConnectorContainerName(), $ar->getArrayForConnector());
212  }
global $ilDB
+ Here is the call graph for this function:

◆ delete()

arConnectorDB::delete ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar

Definition at line 254 of file class.arConnectorDB.php.

References $ilDB, arFieldCache\getPrimaryFieldName(), arFieldCache\getPrimaryFieldType(), and returnDB().

254  {
255  $ilDB = $this->returnDB();
256 
257  $ilDB->manipulate('DELETE FROM ' . $ar->getConnectorContainerName() . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
259  }
static getPrimaryFieldName(ActiveRecord $ar)
static getPrimaryFieldType(ActiveRecord $ar)
global $ilDB
+ Here is the call graph for this function:

◆ installDatabase()

arConnectorDB::installDatabase ( ActiveRecord  $ar,
  $fields 
)
Parameters
ActiveRecord$ar
$fields
Returns
bool

Definition at line 50 of file class.arConnectorDB.php.

References $ilDB, array, ActiveRecord\getArFieldList(), ActiveRecord\getConnectorContainerName(), returnDB(), and updateIndices().

50  {
51  $ilDB = $this->returnDB();
52  $ilDB->createTable($ar->getConnectorContainerName(), $fields);
53  $arFieldList = $ar->getArFieldList();
54  if ($arFieldList->getPrimaryField()->getName()) {
55  $ilDB->addPrimaryKey($ar->getConnectorContainerName(), array( $arFieldList->getPrimaryField()->getName() ));
56  }
57  if ($ar->getArFieldList()->getPrimaryField()->getSequence() AND !$ilDB->sequenceExists($ar->getConnectorContainerName())) {
58  $ilDB->createSequence($ar->getConnectorContainerName());
59  }
60  $this->updateIndices($ar);
61 
62  return true;
63  }
updateIndices(ActiveRecord $ar)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ nextID()

arConnectorDB::nextID ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
mixed

Definition at line 39 of file class.arConnectorDB.php.

References ActiveRecord\getConnectorContainerName(), and returnDB().

39  {
40  return $this->returnDB()->nextId($ar->getConnectorContainerName());
41  }
+ Here is the call graph for this function:

◆ quote()

arConnectorDB::quote (   $value,
  $type 
)
Parameters
$value
$type
Returns
string

Definition at line 348 of file class.arConnectorDB.php.

References $ilDB, arConnector\fixDate(), returnDB(), and ilDBConstants\TYPE_ORACLE.

348  {
349  $ilDB = $this->returnDB();
350 
351  return $ilDB->quote($value, $type);
352  }
global $ilDB
+ Here is the call graph for this function:

◆ read()

arConnectorDB::read ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
array

Definition at line 220 of file class.arConnectorDB.php.

References $ilDB, $query, $records, array, ActiveRecord\getConnectorContainerName(), arFieldCache\getPrimaryFieldName(), arFieldCache\getPrimaryFieldType(), ActiveRecord\getPrimaryFieldValue(), and returnDB().

220  {
221  $ilDB = $this->returnDB();
222 
223  $query = 'SELECT * FROM ' . $ar->getConnectorContainerName() . ' ' . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
225 
226  $set = $ilDB->query($query);
227  $records = array();
228  while ($rec = $ilDB->fetchObject($set)) {
229  $records[] = $rec;
230  }
231 
232  return $records;
233  }
static getPrimaryFieldName(ActiveRecord $ar)
static getPrimaryFieldType(ActiveRecord $ar)
$records
Definition: simple_test.php:22
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ readSet()

arConnectorDB::readSet ( ActiveRecordList  $arl)
Parameters
ActiveRecordList$arl

Definition at line 269 of file class.arConnectorDB.php.

References $ilDB, $records, array, and returnDB().

269  {
270  $ilDB = $this->returnDB();
271  $set = $ilDB->query(self::buildQuery($arl));
272  $records = array();
273  while ($rec = $ilDB->fetchAssoc($set)) {
274  $records[] = $rec;
275  }
276 
277  return $records;
278  }
$records
Definition: simple_test.php:22
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ removeField()

arConnectorDB::removeField ( ActiveRecord  $ar,
  $field_name 
)
Parameters
ActiveRecord$ar
$field_name
Returns
bool
Exceptions
arException

Definition at line 170 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getConnectorContainerName(), and returnDB().

170  {
171  $ilDB = $this->returnDB();
172  if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
173  //throw new arException($field_name, arException::COLUMN_DOES_NOT_EXIST);
174  }
175  if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
176  $ilDB->dropTableColumn($ar->getConnectorContainerName(), $field_name);
177 
178  return true;
179  }
180  }
global $ilDB
+ Here is the call graph for this function:

◆ renameField()

arConnectorDB::renameField ( ActiveRecord  $ar,
  $old_name,
  $new_name 
)
Parameters
ActiveRecord$ar
$old_name
$new_name
Returns
bool
Exceptions
arException

Definition at line 191 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getConnectorContainerName(), and returnDB().

191  {
192  $ilDB = $this->returnDB();
193  if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $old_name)) {
194  //throw new arException($old_name, arException::COLUMN_DOES_NOT_EXIST);
195 
196  if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $new_name)) {
197  //throw new arException($new_name, arException::COLUMN_DOES_ALREADY_EXIST);
198  $ilDB->renameTableColumn($ar->getConnectorContainerName(), $old_name, $new_name);
199  }
200  }
201 
202  return true;
203  }
global $ilDB
+ Here is the call graph for this function:

◆ resetDatabase()

arConnectorDB::resetDatabase ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
bool

Definition at line 109 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getConnectorContainerName(), ActiveRecord\installDB(), and returnDB().

109  {
110  $ilDB = $this->returnDB();
111  if ($ilDB->tableExists($ar->getConnectorContainerName())) {
112  $ilDB->dropTable($ar->getConnectorContainerName());
113  }
114  $ar->installDB();
115 
116  return true;
117  }
global $ilDB
+ Here is the call graph for this function:

◆ returnDB()

arConnectorDB::returnDB ( )
protected
Returns
ilDB

Definition at line 17 of file class.arConnectorDB.php.

References $ilDB.

Referenced by affectedRows(), checkConnection(), checkFieldExists(), checkTableExists(), create(), delete(), installDatabase(), nextID(), quote(), read(), readSet(), removeField(), renameField(), resetDatabase(), truncateDatabase(), update(), updateDatabase(), and updateIndices().

17  {
18  global $ilDB;
19 
20  return $ilDB;
21  }
global $ilDB
+ Here is the caller graph for this function:

◆ truncateDatabase()

arConnectorDB::truncateDatabase ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar

Definition at line 123 of file class.arConnectorDB.php.

References $ilDB, $query, ActiveRecord\getConnectorContainerName(), and returnDB().

123  {
124  $ilDB = $this->returnDB();
125  $query = 'TRUNCATE TABLE ' . $ar->getConnectorContainerName();
126  $ilDB->query($query);
127  if ($ilDB->tableExists($ar->getConnectorContainerName() . '_seq')) {
128  $ilDB->dropSequence($ar->getConnectorContainerName());
129  $ilDB->createSequence($ar->getConnectorContainerName());
130  }
131  }
global $ilDB
+ Here is the call graph for this function:

◆ update()

arConnectorDB::update ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar

Definition at line 239 of file class.arConnectorDB.php.

References $ilDB, array, ActiveRecord\getArrayForConnector(), ActiveRecord\getConnectorContainerName(), arFieldCache\getPrimaryFieldName(), arFieldCache\getPrimaryFieldType(), ActiveRecord\getPrimaryFieldValue(), and returnDB().

239  {
240  $ilDB = $this->returnDB();
241 
245  $ar->getPrimaryFieldValue(),
246  ),
247  ));
248  }
static getPrimaryFieldName(ActiveRecord $ar)
static getPrimaryFieldType(ActiveRecord $ar)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ updateDatabase()

arConnectorDB::updateDatabase ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar
Returns
bool

Definition at line 91 of file class.arConnectorDB.php.

References $ilDB, ActiveRecord\getArFieldList(), ActiveRecord\getConnectorContainerName(), returnDB(), and updateIndices().

91  {
92  $ilDB = $this->returnDB();
93  foreach ($ar->getArFieldList()->getFields() as $field) {
94  if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $field->getName())) {
95  $ilDB->addTableColumn($ar->getConnectorContainerName(), $field->getName(), $field->getAttributesForConnector());
96  }
97  }
98  $this->updateIndices($ar);
99 
100  return true;
101  }
updateIndices(ActiveRecord $ar)
global $ilDB
+ Here is the call graph for this function:

◆ updateIndices()

arConnectorDB::updateIndices ( ActiveRecord  $ar)
Parameters
ActiveRecord$ar

Definition at line 69 of file class.arConnectorDB.php.

References $ilDB, array, ActiveRecord\getArFieldList(), ActiveRecord\getConnectorContainerName(), and returnDB().

Referenced by installDatabase(), and updateDatabase().

69  {
70  $ilDB = $this->returnDB();
71  $arFieldList = $ar->getArFieldList();
72  $existing_indices = $ilDB->loadModule('Manager')->listTableIndexes($ar->getConnectorContainerName());
73 
74  foreach ($arFieldList->getFields() as $i => $arField) {
75  if ($arField->getIndex() === true) {
76  if (!in_array($arField->getName(), $existing_indices)) {
77  if (!$ilDB->indexExistsByFields($ar->getConnectorContainerName(), array( $arField->getName() ))) {
78  $ilDB->addIndex($ar->getConnectorContainerName(), array( $arField->getName() ), 'i' . $i);
79  }
80  }
81  }
82  }
83  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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