ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)

Protected Member Functions

 returnDB ()
 buildQuery (ActiveRecordList $arl)

Detailed Description

Member Function Documentation

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$q = self::buildQuery($arl);
$set = $ilDB->query($q);
return $ilDB->numRows($set);
}

+ Here is the call graph for this function:

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

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

References $tpl, ActiveRecordList\getArConcatCollection(), ActiveRecordList\getArJoinCollection(), ActiveRecordList\getArLimitCollection(), ActiveRecordList\getArOrderCollection(), ActiveRecordList\getArSelectCollection(), ActiveRecordList\getArWhereCollection(), ActiveRecordList\getDebug(), ilUtil\sendInfo(), and ActiveRecordList\setLastQuery().

Referenced by affectedRows().

{
// SELECTS
$q = $arl->getArSelectCollection()->asSQLStatement();
// Concats
$q .= $arl->getArConcatCollection()->asSQLStatement();
$q .= ' FROM '.$arl->getAR()->getConnectorContainerName();
// JOINS
$q .= $arl->getArJoinCollection()->asSQLStatement();
// WHERE
$q .= $arl->getArWhereCollection()->asSQLStatement();
// ORDER
$q .= $arl->getArOrderCollection()->asSQLStatement();
// LIMIT
$q .= $arl->getArLimitCollection()->asSQLStatement();
//TODO: using template in the model.
if ($arl->getDebug()) {
global $tpl;
if ($tpl instanceof ilTemplate) {
} else {
var_dump($q); // FSX
}
}
$arl->setLastQuery($q);
return $q;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented from arConnector.

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

References returnDB().

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

+ Here is the call graph for this function:

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.

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

{
$ilDB = $this->returnDB();
return $ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name);
}

+ Here is the call graph for this function:

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.

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
return $ilDB->tableExists($ar->getConnectorContainerName());
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

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

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$ilDB->manipulate('DELETE FROM ' . $ar->getConnectorContainerName() . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$ilDB->createTable($ar->getConnectorContainerName(), $fields);
$arFieldList = $ar->getArFieldList();
if ($arFieldList->getPrimaryField()->getName()) {
$ilDB->addPrimaryKey($ar->getConnectorContainerName(), array( $arFieldList->getPrimaryField()->getName() ));
}
if ($ar->getArFieldList()->getPrimaryField()->getSequence() AND ! $ilDB->sequenceExists($ar->getConnectorContainerName())) {
$ilDB->createSequence($ar->getConnectorContainerName());
}
$this->updateIndices($ar);
return true;
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

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

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

References $ilDB, and returnDB().

{
$ilDB = $this->returnDB();
return $ilDB->quote($value, $type);
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$query = 'SELECT * FROM ' . $ar->getConnectorContainerName() . ' ' . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = '
$set = $ilDB->query($query);
$records = array();
while ($rec = $ilDB->fetchObject($set)) {
$records[] = $rec;
}
return $records;
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$set = $ilDB->query(self::buildQuery($arl));
$records = array();
while ($rec = $ilDB->fetchAssoc($set)) {
$records[] = $rec;
}
return $records;
}

+ Here is the call graph for this function:

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.

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

{
$ilDB = $this->returnDB();
if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
//throw new arException($field_name, arException::COLUMN_DOES_NOT_EXIST);
}
if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $field_name)) {
$ilDB->dropTableColumn($ar->getConnectorContainerName(), $field_name);
return true;
}
}

+ Here is the call graph for this function:

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.

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

{
$ilDB = $this->returnDB();
if ($ilDB->tableColumnExists($ar->getConnectorContainerName(), $old_name)) {
//throw new arException($old_name, arException::COLUMN_DOES_NOT_EXIST);
if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $new_name)) {
//throw new arException($new_name, arException::COLUMN_DOES_ALREADY_EXIST);
$ilDB->renameTableColumn($ar->getConnectorContainerName(), $old_name, $new_name);
}
}
return true;
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
if ($ilDB->tableExists($ar->getConnectorContainerName())) {
$ilDB->dropTable($ar->getConnectorContainerName());
}
$ar->installDB();
return true;
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
$query = 'TRUNCATE TABLE ' . $ar->getConnectorContainerName();
$ilDB->query($query);
if ($ilDB->tableExists($ar->getConnectorContainerName() . '_seq')) {
$ilDB->dropSequence($ar->getConnectorContainerName());
$ilDB->createSequence($ar->getConnectorContainerName());
}
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

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

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

{
$ilDB = $this->returnDB();
foreach ($ar->getArFieldList()->getFields() as $field) {
if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $field->getName())) {
$ilDB->addTableColumn($ar->getConnectorContainerName(), $field->getName(), $field->getAttributesForConnector());
}
}
return true;
}

+ Here is the call graph for this function:

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

Reimplemented from arConnector.

Reimplemented in arConnectorPdoDB.

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

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

Referenced by installDatabase().

{
$ilDB = $this->returnDB();
$arFieldList = $ar->getArFieldList();
$res = $ilDB->query('SHOW INDEX FROM ' . $ar->getConnectorContainerName());
$existing_indices = array();
while ($rec = $ilDB->fetchObject($res)) {
$existing_indices[] = $rec->column_name;
}
foreach ($arFieldList->getFields() as $i => $arField) {
if ($arField->getIndex() === 'true') {
if (!in_array($arField->getName(), $existing_indices)) {
$ilDB->addIndex($ar->getConnectorContainerName(), array( $arField->getName() ), 'i' . $i);
}
}
}
}

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