/** * @since 2.3 * * @param integer $sid * @param array $dependencyList */ public function updateDependencyList($sid, array $dependencyList) { $this->connection->beginAtomicTransaction(__METHOD__); // Before an insert, delete all entries that for the criteria which is // cheaper then doing an individual upsert or selectRow, this also ensures // that entries are self-corrected for dependencies matched $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__); if ($sid == 0) { return $this->connection->endAtomicTransaction(__METHOD__); } $inserts = array(); foreach ($dependencyList as $dependency) { $oid = $this->getIdForSubject($dependency); if ($oid < 1) { continue; } $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid); } if ($inserts === array()) { return $this->connection->endAtomicTransaction(__METHOD__); } // MW's multi-array insert needs a numeric dimensional array but the key // was used with a hash to avoid duplicate entries hence the re-copy $inserts = array_values($inserts); wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n"); $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__); $this->connection->endAtomicTransaction(__METHOD__); }
/** * @since 2.3 * * @param integer $sid * @param array $dependencyList */ public function updateDependencyList($sid, array $dependencyList) { $this->connection->beginAtomicTransaction(__METHOD__); // Before an insert, delete all entries that for the criteria which is // cheaper then doing an individual upsert or selectRow, this also ensures // that entries are self-corrected for dependencies matched $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__); if ($sid == 0) { return $this->connection->endAtomicTransaction(__METHOD__); } $inserts = array(); foreach ($dependencyList as $dependency) { $oid = $this->getIdForSubject($dependency); // If the ID_TABLE didn't contained an valid ID then we create one ourselves // to ensure that object entities are tracked from the start // This can happen when a query is added with object reference that have not // yet been referenced as annotation and therefore do not recognized as // value annotation if ($oid < 1 && ($oid = $this->tryToMakeIdForSubject($dependency)) < 1) { continue; } $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid); } if ($inserts === array()) { return $this->connection->endAtomicTransaction(__METHOD__); } // MW's multi-array insert needs a numeric dimensional array but the key // was used with a hash to avoid duplicate entries hence the re-copy $inserts = array_values($inserts); wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n"); $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__); $this->connection->endAtomicTransaction(__METHOD__); }
/** * @note This method does not make any assumption about the ID state and therefore * has to be validated before this method is called. * * @since 2.4 * * @param integer $id */ public function cleanUpTableEntriesById($id) { $this->connection->beginAtomicTransaction(__METHOD__); $this->triggerResetCacheEventBy($id); foreach ($this->store->getPropertyTables() as $proptable) { if ($proptable->usesIdSubject()) { $this->connection->delete($proptable->getName(), array('s_id' => $id), __METHOD__); } if (!$proptable->isFixedPropertyTable()) { $this->connection->delete($proptable->getName(), array('p_id' => $id), __METHOD__); } $fields = $proptable->getFields($this->store); // Match tables (including ftp_redi) that contain an object reference if (isset($fields['o_id'])) { $this->connection->delete($proptable->getName(), array('o_id' => $id), __METHOD__); } } $this->doRemoveEntityReferencesById($id); $this->connection->endAtomicTransaction(__METHOD__); }