예제 #1
0
 /**
  * Removes all the rows from the touch table(s)
  * which are marked as deleted (SpyTouchTableMap::COL_ITEM_EVENT_DELETED).
  * Returns the number of Touch entries deleted.
  *
  * @api
  *
  * @throws \Exception
  *
  * @return int
  */
 public function removeTouchEntriesMarkedAsDeleted()
 {
     $this->touchQueryContainer->getConnection()->beginTransaction();
     try {
         $touchListQuery = $this->touchQueryContainer->queryTouchListByItemEvent(SpyTouchTableMap::COL_ITEM_EVENT_DELETED);
         $deletedCount = $this->removeTouchEntries($touchListQuery);
     } catch (\Exception $exception) {
         $this->touchQueryContainer->getConnection()->rollBack();
         throw $exception;
     }
     $this->touchQueryContainer->getConnection()->commit();
     return $deletedCount;
 }
예제 #2
0
 /**
  * @param string $itemType
  * @param int $offset
  *
  * @return \Orm\Zed\Touch\Persistence\SpyTouch[]
  */
 protected function getTouchCollectionToDelete($itemType, $offset = 0)
 {
     $deleteQuery = $this->touchQueryContainer->queryTouchDeleteStorageAndSearch($itemType);
     $deleteQuery->withColumn(SpyTouchTableMap::COL_ID_TOUCH, CollectorConfig::COLLECTOR_TOUCH_ID)->withColumn('search.key', CollectorConfig::COLLECTOR_SEARCH_KEY)->withColumn('storage.key', CollectorConfig::COLLECTOR_STORAGE_KEY)->setOffset($offset)->setLimit($this->chunkSize)->setFormatter(\Propel\Runtime\Formatter\StatementFormatter::class);
     $params = [];
     $sql = $deleteQuery->createSelectSql($params);
     $params = $this->getTouchQueryParameters($deleteQuery);
     $statement = $this->touchQueryContainer->getConnection()->prepare($sql);
     $sqlParams = [];
     $step = 1;
     foreach ($params as $key => $value) {
         $sqlParams['p' . $step] = $value;
         $statement->bindParam(':p' . $step, $value);
         $step++;
     }
     $statement->execute($sqlParams);
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }