Exemple #1
0
 /**
  * Replaces ":site" marker in a search config item array.
  *
  * @param array &$searchAttr Single search config definition including the "internalcode" key
  * @param string $column Name (including alias) of the column containing the site ID in the storage
  * @param integer|array $value Site ID or list of site IDs
  * @param string $marker Marker to replace
  */
 protected function replaceSiteMarker(&$searchAttr, $column, $value, $marker = ':site')
 {
     $types = array('siteid' => \Aimeos\MW\DB\Statement\Base::PARAM_INT);
     $translations = array('siteid' => $column);
     $conn = new \Aimeos\MW\DB\Connection\None();
     $search = new \Aimeos\MW\Criteria\SQL($conn);
     $expr = $search->compare('==', 'siteid', $value);
     $string = $expr->toString($types, $translations);
     $searchAttr['internalcode'] = str_replace($marker, $string, $searchAttr['internalcode']);
 }
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;
 }