Esempio n. 1
0
 public function clean(array $tags, $mode)
 {
     if (!$tags || !$mode) {
         return false;
     }
     switch ($mode) {
         case OW_CacheManager::CLEAN_ALL:
             $this->dbo->query("DELETE FROM `" . $this->getCacheTableName() . "`");
             $this->dbo->query("DELETE FROM `" . $this->getTagsTableName() . "`");
             break;
         case OW_CacheManager::CLEAN_MATCH_ANY_TAG:
             $this->dbo->delete("DELETE `c` FROM `" . $this->getCacheTableName() . "` AS `c` INNER JOIN `" . $this->getTagsTableName() . "` AS `t` ON ( `c`.`id` = `t`.`cacheId` ) WHERE `t`.`tag` IN ( " . $this->dbo->mergeInClause($tags) . " ) ");
             break;
         case OW_CacheManager::CLEAN_MATCH_TAGS:
             throw new LogicException("CLEAN_MATCH_TAGS hasn't been implemeted yet");
             //$cacheIds = $this->dbo->queryForColumnList("SELECT `` ");
             break;
         case OW_CacheManager::CLEAN_NOT_MATCH_TAGS:
             $this->dbo->delete("DELETE `c` FROM `" . $this->getCacheTableName() . "` AS `c` LEFT JOIN `" . $this->getTagsTableName() . "` AS `t` ON ( `c`.`id` = `t`.`cacheId` ) WHERE `t`.`tag` IS NULL OR `t`.`tag` NOT IN ( " . $this->dbo->mergeInClause($tags) . " ) ");
             break;
         case OW_CacheManager::CLEAN_OLD:
             $this->dbo->query("DELETE FROM `" . $this->getCacheTableName() . "` WHERE `expireTimestamp` < :ctime", array('ctime' => time()));
             break;
     }
     $this->dbo->query("DELETE `t` FROM `" . $this->getTagsTableName() . "` AS `t` LEFT JOIN `" . $this->getCacheTableName() . "`  AS `c` on (`t`.`cacheId` = `c`.`id`) WHERE `c`.`id` IS NULL");
 }
Esempio n. 2
0
 public function deleteByExample(OW_Example $example)
 {
     if ($example === null || mb_strlen($example->__toString()) === 0) {
         throw new InvalidArgumentException('example must not be null or empty');
     }
     $sql = 'DELETE FROM ' . $this->getTableName() . $example;
     $this->clearCache();
     return $this->dbo->delete($sql);
 }