Пример #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");
 }
Пример #2
0
 /**
  * Deletes list of entities by id list. Returns affected rows
  *
  * @param array $idList
  * @return int
  */
 public function deleteByIdList(array $idList)
 {
     if ($idList === null || count($idList) === 0) {
         return;
     }
     $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE `id` IN(' . $this->dbo->mergeInClause($idList) . ')';
     $this->clearCache();
     return $this->dbo->delete($sql);
 }
Пример #3
0
 /**
  * @param string $field
  * @param array $valueList
  * @return OW_Example
  */
 public function andFieldNotInArray($field, array $valueList)
 {
     $result = $this->dbo->mergeInClause($valueList);
     $this->criteriaString .= ' AND `' . $this->dbo->escapeString($field) . '` NOT IN(' . $result . ')';
     return $this;
 }