ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 305 of file class.arConnectorDB.php.

306 {
307 $ilDB = $this->returnDB();
308 $q = self::buildQuery($arl);
309
310 $set = $ilDB->query($q);
311
312 return $ilDB->numRows($set);
313 }
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 32 of file class.arConnectorDB.php.

33 {
34 return is_object($this->returnDB());
35 }

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 167 of file class.arConnectorDB.php.

168 {
169 $ilDB = $this->returnDB();
170
171 return $ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name);
172 }

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 149 of file class.arConnectorDB.php.

150 {
151 $ilDB = $this->returnDB();
152
157 return $ilDB->tableExists($ar->getConnectorContainerName());
158 }

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 223 of file class.arConnectorDB.php.

224 {
225 $ilDB = $this->returnDB();
227 }

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 271 of file class.arConnectorDB.php.

272 {
273 $ilDB = $this->returnDB();
274
275 $ilDB->manipulate('DELETE FROM ' . $ar->getConnectorContainerName() . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
277 }
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 55 of file class.arConnectorDB.php.

56 {
57 $ilDB = $this->returnDB();
58 $ilDB->createTable($ar->getConnectorContainerName(), $fields);
59 $arFieldList = $ar->getArFieldList();
60 if ($arFieldList->getPrimaryField()->getName()) {
61 $ilDB->addPrimaryKey($ar->getConnectorContainerName(), array( $arFieldList->getPrimaryField()->getName() ));
62 }
63 if ($ar->getArFieldList()->getPrimaryField()->getSequence() and !$ilDB->sequenceExists($ar->getConnectorContainerName())) {
64 $ilDB->createSequence($ar->getConnectorContainerName());
65 }
66 $this->updateIndices($ar);
67
68 return true;
69 }
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 43 of file class.arConnectorDB.php.

44 {
45 return $this->returnDB()->nextId($ar->getConnectorContainerName());
46 }

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 370 of file class.arConnectorDB.php.

371 {
372 $ilDB = $this->returnDB();
373
374 return $ilDB->quote($value, $type);
375 }
$type

References $ilDB, and $type.

◆ read()

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

Reimplemented from arConnector.

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

236 {
237 $ilDB = $this->returnDB();
238
239 $query = 'SELECT * FROM ' . $ar->getConnectorContainerName() . ' ' . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
241
242 $set = $ilDB->query($query);
243 $records = array();
244 while ($rec = $ilDB->fetchObject($set)) {
245 $records[] = $rec;
246 }
247
248 return $records;
249 }
$query
$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 287 of file class.arConnectorDB.php.

288 {
289 $ilDB = $this->returnDB();
290 $set = $ilDB->query(self::buildQuery($arl));
291 $records = array();
292 while ($rec = $ilDB->fetchAssoc($set)) {
293 $records[] = $rec;
294 }
295
296 return $records;
297 }

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 182 of file class.arConnectorDB.php.

183 {
184 $ilDB = $this->returnDB();
185 if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
186 //throw new arException($field_name, arException::COLUMN_DOES_NOT_EXIST);
187 }
188 if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
189 $ilDB->dropTableColumn($ar->getConnectorContainerName(), $field_name);
190
191 return true;
192 }
193 }

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 204 of file class.arConnectorDB.php.

205 {
206 $ilDB = $this->returnDB();
207 if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $old_name)) {
208 //throw new arException($old_name, arException::COLUMN_DOES_NOT_EXIST);
209
210 if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $new_name)) {
211 //throw new arException($new_name, arException::COLUMN_DOES_ALREADY_EXIST);
212 $ilDB->renameTableColumn($ar->getConnectorContainerName(), $old_name, $new_name);
213 }
214 }
215
216 return true;
217 }

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 117 of file class.arConnectorDB.php.

118 {
119 $ilDB = $this->returnDB();
120 if ($ilDB->tableExists($ar->getConnectorContainerName())) {
121 $ilDB->dropTable($ar->getConnectorContainerName());
122 }
123 $ar->installDB();
124
125 return true;
126 }

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 18 of file class.arConnectorDB.php.

19 {
20 global $DIC;
21 $ilDB = $DIC['ilDB'];
22
23 return $ilDB;
24 }
global $DIC
Definition: saml.php:7

References $DIC, and $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 132 of file class.arConnectorDB.php.

133 {
134 $ilDB = $this->returnDB();
135 $query = 'TRUNCATE TABLE ' . $ar->getConnectorContainerName();
136 $ilDB->query($query);
137 if ($ilDB->tableExists($ar->getConnectorContainerName() . '_seq')) {
138 $ilDB->dropSequence($ar->getConnectorContainerName());
139 $ilDB->createSequence($ar->getConnectorContainerName());
140 }
141 }

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 255 of file class.arConnectorDB.php.

256 {
257 $ilDB = $this->returnDB();
258
259 $ilDB->update($ar->getConnectorContainerName(), $ar->getArrayForConnector(), array(
263 ),
264 ));
265 }

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 98 of file class.arConnectorDB.php.

99 {
100 $ilDB = $this->returnDB();
101 foreach ($ar->getArFieldList()->getFields() as $field) {
102 if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $field->getName())) {
103 $ilDB->addTableColumn($ar->getConnectorContainerName(), $field->getName(), $field->getAttributesForConnector());
104 }
105 }
106 $this->updateIndices($ar);
107
108 return true;
109 }

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 75 of file class.arConnectorDB.php.

76 {
77 $ilDB = $this->returnDB();
78 $arFieldList = $ar->getArFieldList();
79 $existing_indices = $ilDB->loadModule('Manager')->listTableIndexes($ar->getConnectorContainerName());
80
81 foreach ($arFieldList->getFields() as $i => $arField) {
82 if ($arField->getIndex() === true) {
83 if (!in_array($arField->getName(), $existing_indices)) {
84 if (!$ilDB->indexExistsByFields($ar->getConnectorContainerName(), array( $arField->getName() ))) {
85 $ilDB->addIndex($ar->getConnectorContainerName(), array( $arField->getName() ), 'i' . $i);
86 }
87 }
88 }
89 }
90 }
$i
Definition: disco.tpl.php:19

References $i, $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: