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

Reimplemented from arConnector.

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

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

References $ilDB, and returnDB().

+ Here is the call graph for this function:

◆ checkConnection()

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

Reimplemented from arConnector.

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

29 {
30 return is_object($this->returnDB());
31 }

References returnDB().

+ Here is the call graph for this function:

◆ checkFieldExists()

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

Reimplemented from arConnector.

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

156 {
157 $ilDB = $this->returnDB();
158
159 return $ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name);
160 }

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

+ Here is the call graph for this function:

◆ checkTableExists()

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

@TODO: 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.

Reimplemented from arConnector.

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

139 {
140 $ilDB = $this->returnDB();
141
146 return $ilDB->tableExists($ar->getConnectorContainerName());
147 }

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

+ Here is the call graph for this function:

◆ create()

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

Reimplemented from arConnector.

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

209 {
210 $ilDB = $this->returnDB();
212 }

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

+ Here is the call graph for this function:

◆ delete()

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

Reimplemented from arConnector.

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

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)

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

+ Here is the call graph for this function:

◆ installDatabase()

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

Reimplemented from arConnector.

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

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)

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

+ Here is the call graph for this function:

◆ nextID()

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

Reimplemented from arConnector.

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

39 {
40 return $this->returnDB()->nextId($ar->getConnectorContainerName());
41 }

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

+ Here is the call graph for this function:

◆ quote()

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

Reimplemented from arConnector.

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

348 {
349 $ilDB = $this->returnDB();
350
351 return $ilDB->quote($value, $type);
352 }

References $ilDB.

◆ read()

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

Reimplemented from arConnector.

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

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 }
$records
Definition: simple_test.php:22

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

+ Here is the call graph for this function:

◆ readSet()

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

Reimplemented from arConnector.

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

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 }

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

+ Here is the call graph for this function:

◆ removeField()

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

Reimplemented from arConnector.

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

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 }

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

+ 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

Reimplemented from arConnector.

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

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 }

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

+ Here is the call graph for this function:

◆ resetDatabase()

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

Reimplemented from arConnector.

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

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 }

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

+ Here is the call graph for this function:

◆ returnDB()

arConnectorDB::returnDB ( )
protected
Returns
ilDB

Reimplemented in arConnectorPdoDB.

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

17 {
18 global $ilDB;
19
20 return $ilDB;
21 }

References $ilDB.

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

+ Here is the caller graph for this function:

◆ truncateDatabase()

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

Reimplemented from arConnector.

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

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 }

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

+ Here is the call graph for this function:

◆ update()

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

Reimplemented from arConnector.

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

239 {
240 $ilDB = $this->returnDB();
241
242 $ilDB->update($ar->getConnectorContainerName(), $ar->getArrayForConnector(), array(
246 ),
247 ));
248 }

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

+ Here is the call graph for this function:

◆ updateDatabase()

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

Reimplemented from arConnector.

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

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 }

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

+ Here is the call graph for this function:

◆ updateIndices()

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

Reimplemented from arConnector.

Reimplemented in arConnectorPdoDB.

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

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 }

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

Referenced by installDatabase(), and updateDatabase().

+ 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: