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

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

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

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

◆ checkConnection()

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

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

References returnDB().

33  {
34  return is_object($this->returnDB());
35  }
+ 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 167 of file class.arConnectorDB.php.

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

168  {
169  $ilDB = $this->returnDB();
170 
171  return $ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name);
172  }
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 149 of file class.arConnectorDB.php.

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

150  {
151  $ilDB = $this->returnDB();
152 
157  return $ilDB->tableExists($ar->getConnectorContainerName());
158  }
global $ilDB
+ Here is the call graph for this function:

◆ create()

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

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

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

224  {
225  $ilDB = $this->returnDB();
226  $ilDB->insert($ar->getConnectorContainerName(), $ar->getArrayForConnector());
227  }
global $ilDB
+ Here is the call graph for this function:

◆ delete()

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

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

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

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

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

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

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

44  {
45  return $this->returnDB()->nextId($ar->getConnectorContainerName());
46  }
+ Here is the call graph for this function:

◆ quote()

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

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

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

371  {
372  $ilDB = $this->returnDB();
373 
374  return $ilDB->quote($value, $type);
375  }
$type
global $ilDB
+ Here is the call graph for this function:

◆ read()

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

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

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

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  }
static getPrimaryFieldName(ActiveRecord $ar)
static getPrimaryFieldType(ActiveRecord $ar)
$records
Definition: simple_test.php:22
$query
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 287 of file class.arConnectorDB.php.

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

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

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

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

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

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

◆ resetDatabase()

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

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

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

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

◆ returnDB()

arConnectorDB::returnDB ( )
protected
Returns
ilDB

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

References $DIC, and $ilDB.

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

19  {
20  global $DIC;
21  $ilDB = $DIC['ilDB'];
22 
23  return $ilDB;
24  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ truncateDatabase()

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

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

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

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  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ update()

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

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

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

256  {
257  $ilDB = $this->returnDB();
258 
262  $ar->getPrimaryFieldValue(),
263  ),
264  ));
265  }
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 98 of file class.arConnectorDB.php.

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

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  }
updateIndices(ActiveRecord $ar)
global $ilDB
+ Here is the call graph for this function:

◆ updateIndices()

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

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

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

Referenced by installDatabase(), and updateDatabase().

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  }
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
+ 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: