Bug #23980 » bug_16292.patch
class.t3lib_loaddbgroup.php 2010-11-07 17:16:34.000000000 +0100 | ||
---|---|---|
var $MM_match_fields = array(); // array of fields value pairs that should match while SELECT and will be written into MM table if $MM_insert_fields is not set
|
||
var $MM_insert_fields = array(); // array of fields and value pairs used for insert in MM table
|
||
var $MM_table_where = ''; // extra MM table where
|
||
var $foreignField; // the foreign field
|
||
/**
|
||
... | ... | |
next($this->tableArray);
|
||
$this->secondTable = key($this->tableArray); // If the second table is set and the ID number is less than zero (later) then the record is regarded to come from the second table...
|
||
// Set the foreignField to use is later to update the count
|
||
$this->foreignField = $conf['foreign_field'];
|
||
// Now, populate the internal itemArray and tableArray arrays:
|
||
if ($MMtable) { // If MM, then call this function to do that:
|
||
if ($MMuid) {
|
||
... | ... | |
* @return void
|
||
*/
|
||
function writeMM($MM_tableName,$uid,$prependTableName=0) {
|
||
if ($this->MM_is_foreign) { // in case of a reverse relation
|
||
$uidLocal_field = 'uid_foreign';
|
||
$uidForeign_field = 'uid_local';
|
||
... | ... | |
$this->updateRefIndex($val['table'], $val['id']);
|
||
}
|
||
}
|
||
// update the value of the opposite table
|
||
if ($this->MM_is_foreign) {
|
||
//count the relations
|
||
$whereClause = $uidForeign_field . " = " . $val['id'];
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $MM_tableName, $whereClause);
|
||
//update the count
|
||
$whereClause = "uid = " . $val['id'];
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->MM_oppositeTable, $whereClause, array($this->MM_oppositeField => $count));
|
||
}
|
||
else {
|
||
//count the relations
|
||
$whereClause = $uidForeign_field . " = " . $val['id'];
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $MM_tableName, $whereClause);
|
||
//update the count
|
||
$whereClause = "uid = " . $val['id'];
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($tablename, $whereClause, array($this->foreignField => $count));
|
||
}
|
||
|
||
}
|
||
// Delete all not-used relations:
|
||
... | ... | |
$updateRefIndex_records[] = array($this->firstTable,$mmItem);
|
||
}
|
||
}
|
||
}
|
||
$deleteAddWhere = ' AND ('.implode(' OR ', $removeClauses).')';
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery($MM_tableName, $uidLocal_field.'='.intval($uid).$deleteAddWhere.$additionalWhere_tablenames.$additionalWhere);
|
||
if (!$this->MM_is_foreign) {
|
||
$whereClause = $uidForeign_field . " = " . $mmItem[1];
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $MM_tableName, $whereClause);
|
||
//update the count
|
||
$whereClause = "uid = " . $mmItem[1];
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($tablename, $whereClause, array($this->foreignField => $count));
|
||
}
|
||
// Update ref index:
|
||
foreach($updateRefIndex_records as $pair) {
|
||
$this->updateRefIndex($pair[0],$pair[1]);
|
||
}
|
||
// update the value of the opposite table
|
||
//count the relations
|
||
$whereClause = $uidLocal_field . " = " . $pair[1];
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $MM_tableName, $whereClause);
|
||
//update the count
|
||
$whereClause = "uid = " . $pair[1];
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->MM_oppositeTable, $whereClause, array($this->MM_oppositeField => $count));
|
||
}
|
||
|
||
}
|
||
// Update ref index; In tcemain it is not certain that this will happen because if only the MM field is changed the record itself is not updated and so the ref-index is not either. This could also have been fixed in updateDB in tcemain, however I decided to do it here ...
|
||
$this->updateRefIndex($this->currentTable,$uid);
|
||
}
|
||
}
|
||
/**
|