/**
  * @since 2.4
  *
  * @param integer $id
  */
 public function removeAnyReferenceFromPropertyTablesFor($id)
 {
     $db = $this->store->getConnection('mw.db');
     foreach ($this->store->getPropertyTables() as $proptable) {
         if ($proptable->usesIdSubject()) {
             $db->delete($proptable->getName(), array('s_id' => $id), __METHOD__);
         }
         $fields = $proptable->getFields($this->store);
         // Match tables (including ftp_redi) that contain an object reference
         if (isset($fields['o_id'])) {
             $db->delete($proptable->getName(), array('o_id' => $id), __METHOD__);
         }
     }
     $db->delete(SQLStore::ID_TABLE, array('smw_id' => $id), __METHOD__);
 }
 /**
  * @since 2.5
  *
  * @return Table[]
  */
 public function getTables()
 {
     if ($this->tables !== array()) {
         return $this->tables;
     }
     $this->addTable($this->newEntityIdTable());
     $this->addTable($this->newConceptCacheTable());
     $this->addTable($this->newQueryLinksTable());
     $this->addTable($this->newFulltextSearchTable());
     $this->addTable($this->newPropertyStatisticsTable());
     foreach ($this->store->getPropertyTables() as $propertyTable) {
         // Only extensions that aren't setup correctly can force an exception
         // and to avoid a failure during setup, ensure that standard tables
         // are correctly initialized otherwise SMW can't recover
         try {
             $diHandler = $this->store->getDataItemHandlerForDIType($propertyTable->getDiType());
         } catch (\Exception $e) {
             continue;
         }
         $this->addTable($this->newPropertyTable($propertyTable, $diHandler));
     }
     return $this->tables;
 }
 /**
  * @since 2.4
  *
  * @param integer $id
  *
  * @return DataItem|false
  */
 public function tryToFindAtLeastOneReferenceForId($id)
 {
     $reference = false;
     foreach ($this->store->getPropertyTables() as $proptable) {
         if (($reference = $this->findReferenceByPropertyTable($proptable, $id)) !== false) {
             break;
         }
     }
     // If null is returned it means that a reference was found bu no DI could
     // be matched therefore is categorized as false positive
     if (isset($reference->s_id)) {
         $reference = $this->store->getObjectIds()->getDataItemById($reference->s_id);
     }
     return $reference === false || $reference === null ? false : $reference;
 }
 /**
  * @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__);
 }