ILIAS  release_7 Revision v7.30-3-g800a261c036
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)
 
 fixDate ($value)
 
 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 ()
 
 buildQuery (ActiveRecordList $arl)
 

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 }
buildQuery(ActiveRecordList $arl)
global $ilDB

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

Referenced by arConnectorCache\affectedRows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuery()

arConnectorDB::buildQuery ( ActiveRecordList  $arl)
protected
Parameters
ActiveRecordList$arl
Returns
mixed|string

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

322 {
323 $method = 'asSQLStatement';
324
325 // SELECTS
326 $q = $arl->getArSelectCollection()->{$method}();
327 // Concats
328 $q .= $arl->getArConcatCollection()->{$method}();
329 $q .= ' FROM ' . $arl->getAR()->getConnectorContainerName();
330 // JOINS
331 $q .= $arl->getArJoinCollection()->{$method}();
332 // WHERE
333 $q .= $arl->getArWhereCollection()->{$method}();
334 // HAVING
335 $q .= $arl->getArHavingCollection()->{$method}();
336 // ORDER
337 $q .= $arl->getArOrderCollection()->{$method}();
338 // LIMIT
339 $q .= $arl->getArLimitCollection()->{$method}();
340
341 //TODO: using template in the model.
342 if ($arl->getDebug()) {
343 global $DIC;
344 $tpl = $DIC['tpl'];
345 if ($tpl instanceof ilTemplate) {
347 } else {
348 var_dump($q); // FSX
349 }
350 }
351 $arl->setLastQuery($q);
352
353 return $q;
354 }
static setLastQuery($last_query)
special template class to simplify handling of ITX/PEAR
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References ActiveRecordList\getArSelectCollection().

Referenced by affectedRows().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\checkConnection().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\checkFieldExists().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\checkTableExists().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\create().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixDate()

arConnectorDB::fixDate (   $value)
Parameters
$value
Returns
string

Reimplemented from arConnector.

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

376 {
377 return parent::fixDate($value);
378 }

◆ 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().

Referenced by arConnectorCache\installDatabase().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\nextID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quote()

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

Reimplemented from arConnector.

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

364 {
365 $ilDB = $this->returnDB();
366
367 return $ilDB->quote($value, $type);
368 }
$type

References $ilDB, and $type.

Referenced by arConnectorCache\quote().

+ Here is the caller graph for this function:

◆ 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

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

Referenced by arConnectorCache\read().

+ Here is the call graph for this function:
+ Here is the caller 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, and returnDB().

Referenced by arConnectorCache\readSet().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\removeField().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\renameField().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\resetDatabase().

+ Here is the call graph for this function:
+ Here is the caller 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 }

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().

Referenced by arConnectorCache\truncateDatabase().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\update().

+ Here is the call graph for this function:
+ Here is the caller 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().

Referenced by arConnectorCache\updateDatabase().

+ Here is the call graph for this function:
+ Here is the caller 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: metadata.php:24

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

Referenced by installDatabase(), updateDatabase(), and arConnectorCache\updateIndices().

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