Exemple #1
0
 /**
  * Sets the base criteria "status".
  * (setConditions overwrites the base criteria)
  *
  * @param string $domain Name of the domain/sub-domain like "product" or "product.list"
  * @return \Aimeos\MW\Criteria\Iface Search critery object
  */
 protected function createSearchBase($domain)
 {
     $dbm = $this->context->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     $object = new \Aimeos\MW\Criteria\SQL($conn);
     $object->setConditions($object->compare('==', $domain . '.status', 1));
     $dbm->release($conn, $dbname);
     return $object;
 }
Exemple #2
0
 /**
  * Returns the cached keys and values associated to the given tags if available.
  *
  * @inheritDoc
  *
  * @param string[] $tags List of tag strings associated to the requested cache entries
  * @return array Associative list of key/value pairs for the requested cache
  * 	entries. If a tag isn't associated to any cache entry, nothing is returned
  * 	for that tag
  * @throws \Aimeos\MW\Cache\Exception If the cache server doesn't respond
  */
 public function getListByTags(array $tags)
 {
     $list = array();
     $conn = $this->dbm->acquire($this->dbname);
     try {
         $search = new \Aimeos\MW\Criteria\SQL($conn);
         $expires = array($search->compare('>', 'cache.expire', date('Y-m-d H:i:00')), $search->compare('==', 'cache.expire', null));
         $expr = array($search->compare('==', 'cache.tag.name', $tags), $search->combine('||', $expires));
         $search->setConditions($search->combine('&&', $expr));
         $types = $this->getSearchTypes($this->searchConfig);
         $translations = $this->getSearchTranslations($this->searchConfig);
         $conditions = $search->getConditionString($types, $translations);
         $stmt = $conn->create(str_replace(':cond', $conditions, $this->sql['getbytag']));
         $stmt->bind(1, $this->siteid, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
         $stmt->bind(2, $this->siteid, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
         $result = $stmt->execute();
         while (($row = $result->fetch()) !== false) {
             $list[$row['id']] = $row['value'];
         }
         $this->dbm->release($conn, $this->dbname);
     } catch (\Exception $e) {
         $this->dbm->release($conn, $this->dbname);
         throw $e;
     }
     return $list;
 }
Exemple #3
0
 /**
  * creates a search object and sets base criteria
  *
  * @param boolean $default
  * @return \Aimeos\MW\Criteria\Iface
  */
 public function createSearch($default = false)
 {
     $dbm = $this->getContext()->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     $object = new \Aimeos\MW\Criteria\SQL($conn);
     $dbm->release($conn, $dbname);
     if ($default === true) {
         $curDate = date('Y-m-d H:i:00', time());
         $expr = array($object->compare('>', 'coupon.code.count', 0));
         $temp = array();
         $temp[] = $object->compare('==', 'coupon.code.datestart', null);
         $temp[] = $object->compare('<=', 'coupon.code.datestart', $curDate);
         $expr[] = $object->combine('||', $temp);
         $temp = array();
         $temp[] = $object->compare('==', 'coupon.code.dateend', null);
         $temp[] = $object->compare('>=', 'coupon.code.dateend', $curDate);
         $expr[] = $object->combine('||', $temp);
         $object->setConditions($object->combine('&&', $expr));
     }
     return $object;
 }