/** * Creates a criteria object for searching. * * @param boolean $default Include default criteria like the status * @return MW_Common_Criteria_Interface Search criteria object */ public function createSearch($default = false) { if ($default === true) { $dbm = $this->_getContext()->getDatabaseManager(); $conn = $dbm->acquire(); $object = new MW_Common_Criteria_SQL($conn); $object->setConditions($object->compare('==', 'customer.status', 1)); $dbm->release($conn); return $object; } return parent::createSearch(); }
/** * 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 MW_Common_Criteria_Interface Search critery object */ protected function _createSearch($domain) { $dbm = $this->_context->getDatabaseManager(); $dbname = $this->_getResourceName(); $conn = $dbm->acquire($dbname); $object = new MW_Common_Criteria_SQL($conn); $object->setConditions($object->compare('>', $domain . '.status', 0)); $dbm->release($conn, $dbname); return $object; }
/** * 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 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 MW_Common_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, MW_DB_Statement_Abstract::PARAM_INT); $stmt->bind(2, $this->_siteid, MW_DB_Statement_Abstract::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; }
/** * creates a search object and sets base criteria * * @param boolean $default * @return MW_Common_Criteria_Interface */ public function createSearch($default = false) { $dbm = $this->_getContext()->getDatabaseManager(); $dbname = $this->_getResourceName(); $conn = $dbm->acquire($dbname); $object = new MW_Common_Criteria_SQL($conn); $dbm->release($conn, $dbname); if ($default === true) { $curDate = date('Y-m-d H:i:00', time()); $expr = array(); $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; }