コード例 #1
0
ファイル: Typo3.php プロジェクト: arcavias/ext-typo3
 /**
  * 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();
 }
コード例 #2
0
ファイル: Abstract.php プロジェクト: arcavias/arcavias-core
 /**
  * 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' => MW_DB_Statement_Abstract::PARAM_INT);
     $translations = array('siteid' => $column);
     $conn = new MW_DB_Connection_None();
     $search = new MW_Common_Criteria_SQL($conn);
     $expr = $search->compare('==', 'siteid', $value);
     $string = $expr->toString($types, $translations);
     $searchAttr['internalcode'] = str_replace($marker, $string, $searchAttr['internalcode']);
 }
コード例 #3
0
ファイル: DB.php プロジェクト: arcavias/arcavias-core
 /**
  * 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;
 }
コード例 #4
0
ファイル: Default.php プロジェクト: arcavias/arcavias-core
 /**
  * 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;
 }