• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DataQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中DataQuery的典型用法代码示例。如果您正苦于以下问题:PHP DataQuery类的具体用法?PHP DataQuery怎么用?PHP DataQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DataQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: augmentSQL

 /**
  * Update any requests to limit the results to the current site
  */
 public function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     $ctrl = null;
     if (Controller::has_curr()) {
         $ctrl = Controller::curr();
     }
     if (Subsite::$disable_subsite_filter) {
         return;
     }
     if ($dataQuery->getQueryParam('Subsite.filter') === false) {
         return;
     }
     if ($ctrl && get_class(Controller::curr()) == 'Security') {
         return;
     }
     // Don't run on delete queries, since they are always tied to
     // a specific ID.
     if ($query->getDelete()) {
         return;
     }
     // If you're querying by ID, ignore the sub-site - this is a bit ugly...
     // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
     if (!$query->filtersOnID()) {
         if (Subsite::$force_subsite) {
             $subsiteID = Subsite::$force_subsite;
         } else {
             $subsiteID = (int) Subsite::currentSubsiteID();
         }
         $froms = $query->getFrom();
         $froms = array_keys($froms);
         $tableName = array_shift($froms);
         $query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
     }
 }
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:37,代码来源:EmailTemplateSubsiteExtension.php


示例2: augmentSQL

 /**
  * Update any requests to limit the results to the current site
  */
 function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     if (Subsite::$disable_subsite_filter) {
         return;
     }
     if ($dataQuery->getQueryParam('Subsite.filter') === false) {
         return;
     }
     // Don't run on delete queries, since they are always tied to
     // a specific ID.
     if ($query->getDelete()) {
         return;
     }
     // If you're querying by ID, ignore the sub-site - this is a bit ugly...
     // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
     if (!$query->where || !preg_match('/\\.(\'|"|`|)ID(\'|"|`|)( ?)=/', $query->where[0])) {
         if (Subsite::$force_subsite) {
             $subsiteID = Subsite::$force_subsite;
         } else {
             /*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
               else */
             $subsiteID = (int) Subsite::currentSubsiteID();
         }
         // The foreach is an ugly way of getting the first key :-)
         foreach ($query->getFrom() as $tableName => $info) {
             // The tableName should be SiteTree or SiteTree_Live...
             if (strpos($tableName, $this->owner->ClassName) === false) {
                 break;
             }
             $query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
             break;
         }
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:37,代码来源:Ext_Subsites_Commerce.php


示例3: augmentSQL

 public function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     // Actives locales defined on a SiteConfig are there as a global setting
     if ($this->owner instanceof SiteConfig) {
         return;
     }
     // In admin, show everthing anyway
     if ($this->isAdminBackend()) {
         return;
     }
     // Find in set is only compatible with MySql
     $c = DB::getConn();
     if (!$c instanceof MySQLDatabase) {
         return;
     }
     $locale = $dataQuery->getQueryParam('Fluent.Locale') ?: Fluent::current_locale();
     $from = $query->getFrom();
     $where = $query->getWhere();
     $column = 'ActiveLocales';
     $table = null;
     // Check on which table is the ActiveLocales field
     foreach ($from as $fromTable => $conditions) {
         if ($table === null) {
             $table = $fromTable;
         }
         $db = DataObject::custom_database_fields($fromTable);
         if ($db && isset($db[$column])) {
             $table = $fromTable;
             break;
         }
     }
     $identifier = "\"{$table}\".\"{$column}\"";
     $where[] = "{$identifier} IS NULL OR FIND_IN_SET ('{$locale}', {$identifier}) > 0";
     $query->setWhere($where);
 }
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:35,代码来源:ActiveLocalesExtension.php


示例4: augmentSQL

 /**
  * Update any requests to limit the results to the current site
  */
 public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = NULL)
 {
     if (Subsite::$disable_subsite_filter) {
         return;
     }
     if ($dataQuery->getQueryParam('Subsite.filter') === false) {
         return;
     }
     // If you're querying by ID, ignore the sub-site - this is a bit ugly...
     // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
     if ($query->filtersOnID()) {
         return;
     }
     if (Subsite::$force_subsite) {
         $subsiteID = Subsite::$force_subsite;
     } else {
         /*if($context = DataObject::context_obj()) $subsiteID = (int)$context->SubsiteID;
           else */
         $subsiteID = (int) Subsite::currentSubsiteID();
     }
     // The foreach is an ugly way of getting the first key :-)
     foreach ($query->getFrom() as $tableName => $info) {
         // The tableName should be SiteTree or SiteTree_Live...
         if (strpos($tableName, 'SiteTree') === false) {
             break;
         }
         $query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
         break;
     }
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:33,代码来源:SiteTreeSubsites.php


示例5: apply

 /**
  * Applies the filter.
  * Builds the where clause with the given IDs and boolean values in
  * $this->value
  * 
  * @param DataQuery $query Query to build where clause for
  * 
  * @return DataQuery
  * 
  * @author Sebastian Diel <[email protected]>
  * @since 25.06.2014
  */
 public function apply(DataQuery $query)
 {
     $result = false;
     $value = $this->getValue();
     if (is_array($value) && count($value) > 0) {
         $this->model = $query->applyRelation($this->relation);
         $values = array(0 => array(), 1 => array());
         foreach ($value as $ID => $boolean) {
             $operator = '!=';
             if ($boolean) {
                 $operator = '=';
             }
             $values[$boolean][] = sprintf("%s %s '%s'", $this->getDbName(), $operator, Convert::raw2sql($ID));
         }
         $negativeWhereClause = implode(' AND ', $values[0]);
         $positiveWhereClause = implode(' OR ', $values[1]);
         if (count($values[0]) > 0 && count($values[1]) > 0) {
             $where = sprintf('(%s) AND (%s)', $negativeWhereClause, $positiveWhereClause);
         } elseif (count($values[0]) > 0) {
             $where = $negativeWhereClause;
         } else {
             $where = $positiveWhereClause;
         }
         $result = $query->where($where);
     }
     return $result;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:39,代码来源:SilvercartExactMatchBooleanMultiFilter.php


示例6: apply

 public function apply(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     // hack
     // PREVIOUS $values = explode(',',$this->getValue());
     $values = array();
     if (is_string($this->getValue())) {
         $values = explode(',', $this->getValue());
     } else {
         foreach ($this->getValue() as $v) {
             $values[] = $v;
         }
     }
     if (!$values) {
         return false;
     }
     for ($i = 0; $i < count($values); $i++) {
         if (!is_numeric($values[$i])) {
             // @todo Fix string replacement to only replace leading and tailing quotes
             $values[$i] = str_replace("'", '', $values[$i]);
             $values[$i] = Convert::raw2sql($values[$i]);
         }
     }
     $SQL_valueStr = "'" . implode("','", $values) . "'";
     return $query->where(sprintf("%s IN (%s)", $this->getDbName(), $SQL_valueStr));
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:26,代码来源:ExactMatchMultiFilter.php


示例7: getQuery

 /**
  * @return \SQLQuery
  */
 public function getQuery()
 {
     if (!$this->queryCache) {
         if ($this->dataClass) {
             $dataQuery = new \DataQuery($this->dataClass);
             if ($this->stage) {
                 $dataQuery->setQueryParam('Versioned.mode', 'stage');
                 $dataQuery->setQueryParam('Versioned.stage', $this->stage);
             }
             $this->queryCache = $dataQuery->getFinalisedQuery();
         } else {
             $this->queryCache = new \SQLQuery();
         }
         if (is_array($this->queryModifiers)) {
             foreach ($this->queryModifiers as $queryModifier) {
                 if ($queryModifier instanceof QueryModifierInterface) {
                     $queryModifier->modify($this->queryCache, $this->data, $this);
                 } elseif (is_callable($queryModifier)) {
                     $queryModifier($this->queryCache, $this->data, $this);
                 }
             }
         }
     }
     return $this->queryCache;
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-querybuilder,代码行数:28,代码来源:QueryBuilder.php


示例8: apply

	public function apply(DataQuery $query) {
		$query->where(sprintf(
			"MATCH (%s) AGAINST ('%s')",
			$this->getDbName(),
			Convert::raw2sql($this->getValue())
		));
		return $query;
	}
开发者ID:redema,项目名称:sapphire,代码行数:8,代码来源:FulltextFilter.php


示例9: apply

	/**
	 * @return $query
	 */
	public function apply(DataQuery $query) {
		$this->model = $query->applyRelation($this->relation);
		return $query->where(sprintf(
			"%s > '%s'",
			$this->getDbName(),
			Convert::raw2sql($this->getDbFormattedValue())
		));
	}
开发者ID:redema,项目名称:sapphire,代码行数:11,代码来源:GreaterThanFilter.php


示例10: augmentSQL

 /**
  * @param SQLQuery $query
  * @param DataQuery $dataQuery
  */
 function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     $baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
     if (class_exists('Subsite')) {
         $currentSubsiteID = Subsite::currentSubsiteID();
         $query->addWhere("\"{$baseTable}\".\"SubsiteID\" = '{$currentSubsiteID}'");
     }
 }
开发者ID:helpfulrobot,项目名称:moe-subsite-config,代码行数:12,代码来源:SubsiteDataObject.php


示例11: apply

	function apply(DataQuery $query) {
		$query->where(sprintf(
			"%s >= %s AND %s <= %s",
			$this->getDbName(),
			Convert::raw2sql($this->min),
			$this->getDbName(),
			Convert::raw2sql($this->max)
		));
	}
开发者ID:redema,项目名称:sapphire,代码行数:9,代码来源:WithinRangeFilter.php


示例12: testJoins

	/**
	 * Test the leftJoin() and innerJoin method of the DataQuery object
	 */
	function testJoins() {
		$dq = new DataQuery('Member');
		$dq->innerJoin("Group_Members", "\"Group_Members\".\"MemberID\" = \"Member\".\"ID\"");
		$this->assertContains("INNER JOIN \"Group_Members\" ON \"Group_Members\".\"MemberID\" = \"Member\".\"ID\"", $dq->sql());

		$dq = new DataQuery('Member');
		$dq->leftJoin("Group_Members", "\"Group_Members\".\"MemberID\" = \"Member\".\"ID\"");
		$this->assertContains("LEFT JOIN \"Group_Members\" ON \"Group_Members\".\"MemberID\" = \"Member\".\"ID\"", $dq->sql());
	}
开发者ID:redema,项目名称:sapphire,代码行数:12,代码来源:DataQueryTest.php


示例13: excludeMany

 protected function excludeMany(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $where = array();
     $modifiers = $this->getModifiers();
     foreach ($this->getValue() as $value) {
         $where[] = DB::getConn()->comparisonClause($this->getDbName(), '%' . Convert::raw2sql($value) . '%', false, true, $this->getCaseSensitive());
     }
     return $query->where(implode(' AND ', $where));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:10,代码来源:PartialMatchFilter.php


示例14: apply

 /**
  * @return $query
  */
 public function apply(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $value = $this->getDbFormattedValue();
     if (is_numeric($value)) {
         $filter = sprintf("%s < %s", $this->getDbName(), Convert::raw2sql($value));
     } else {
         $filter = sprintf("%s < '%s'", $this->getDbName(), Convert::raw2sql($value));
     }
     return $query->where($filter);
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:14,代码来源:LessThanFilter.php


示例15: excludeOne

 /**
  * Applies a exclusion(inverse) filter to the query
  * Handles SQL escaping for both numeric and string values
  *
  * @param DataQuery $query
  * @return $this|DataQuery
  */
 protected function excludeOne(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $value = $this->getDbFormattedValue();
     if (is_numeric($value)) {
         $filter = sprintf("%s %s %s", $this->getDbName(), $this->getInverseOperator(), Convert::raw2sql($value));
     } else {
         $filter = sprintf("%s %s '%s'", $this->getDbName(), $this->getInverseOperator(), Convert::raw2sql($value));
     }
     return $query->where($filter);
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:18,代码来源:ComparisonFilter.php


示例16: testSubgroupHandoff

 public function testSubgroupHandoff()
 {
     $dq = new DataQuery('DataQueryTest_A');
     $subDq = $dq->disjunctiveGroup();
     $orgDq = clone $dq;
     $subDq->sort('"DataQueryTest_A"."Name"');
     $orgDq->sort('"DataQueryTest_A"."Name"');
     $this->assertEquals($dq->sql(), $orgDq->sql());
     $subDq->limit(5, 7);
     $orgDq->limit(5, 7);
     $this->assertEquals($dq->sql(), $orgDq->sql());
 }
开发者ID:normann,项目名称:sapphire,代码行数:12,代码来源:DataQueryTest.php


示例17: excludeMany

 /**
  * @param DataQuery $query
  * @return DataQuery
  */
 protected function excludeMany(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $filters = array();
     $ops = array('<', '>');
     foreach ($this->getValue() as $i => $value) {
         if (is_numeric($value)) {
             $filters[] = sprintf("%s %s %s", $this->getDbName(), $ops[$i], Convert::raw2sql($value));
         } else {
             $filters[] = sprintf("%s %s '%s'", $this->getDbName(), $ops[$i], Convert::raw2sql($value));
         }
     }
     return $query->where(implode(' OR ', $filters));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-search,代码行数:18,代码来源:BetweenFilter.php


示例18: apply

 public function apply(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $where = array();
     $comparison = DB::getConn() instanceof PostgreSQLDatabase ? 'ILIKE' : 'LIKE';
     if (is_array($this->getValue())) {
         foreach ($this->getValue() as $value) {
             $where[] = sprintf("%s %s '%%%s%%'", $this->getDbName(), $comparison, Convert::raw2sql($value));
         }
     } else {
         $where[] = sprintf("%s %s '%%%s%%'", $this->getDbName(), $comparison, Convert::raw2sql($this->getValue()));
     }
     return $query->where(implode(' OR ', $where));
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:14,代码来源:PartialMatchFilter.php


示例19: excludeMany

 protected function excludeMany(DataQuery $query)
 {
     $this->model = $query->applyRelation($this->relation);
     $values = $this->getValue();
     $comparisonClause = DB::get_conn()->comparisonClause($this->getDbName(), null, false, true, $this->getCaseSensitive(), true);
     $parameters = array();
     foreach ($values as $value) {
         $parameters[] = $this->getMatchPattern($value);
     }
     // Since query connective is ambiguous, use AND explicitly here
     $count = count($values);
     $predicate = implode(' AND ', array_fill(0, $count, $comparisonClause));
     return $query->where(array($predicate => $parameters));
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:14,代码来源:PartialMatchFilter.php


示例20: apply

	public function apply(DataQuery $query) {
		$this->model = $query->applyRelation($this->relation);
		$where = array();
		if(is_array($this->getValue())) {
			foreach($this->getValue() as $value) {
				$where[]= sprintf("%s LIKE '%%%s%%'", $this->getDbName(), Convert::raw2sql($value));
			}

		} else {
			$where[] = sprintf("%s LIKE '%%%s%%'", $this->getDbName(), Convert::raw2sql($this->getValue()));
		}

		return $query->where(implode(' OR ', $where));
	}
开发者ID:redema,项目名称:sapphire,代码行数:14,代码来源:PartialMatchFilter.php



注:本文中的DataQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DataSource类代码示例发布时间:2022-05-23
下一篇:
PHP DataProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap