当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::create方法代码示例

本文整理汇总了PHP中Query::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::create方法的具体用法?PHP Query::create怎么用?PHP Query::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


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

示例1: matchDoc

 /**
  * Match a document to percolator queries
  *
  * @param  \Elastica\Document                                   $doc
  * @param  string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
  *                                                                     are executed.
  * @param  string                                               $type
  * @return array With matching registered queries.
  */
 public function matchDoc(Document $doc, $query = null, $type = 'type')
 {
     $path = $this->_index->getName() . '/' . $type . '/_percolate';
     $data = array('doc' => $doc->getData());
     // Add query to filter the percolator queries which are executed.
     if ($query) {
         $query = Query::create($query);
         $data['query'] = $query->getQuery();
     }
     $response = $this->getIndex()->getClient()->request($path, Request::GET, $data);
     $data = $response->getData();
     return $data['matches'];
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:22,代码来源:Percolator.php

示例2: matchDoc

 /**
  * Match a document to percolator queries
  *
  * @param  \Elastica\Document                                  $doc
  * @param  string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the data
  * @return \Elastica\Response
  */
 public function matchDoc(Document $doc, $query = null)
 {
     $path = $this->_index->getName() . '/type/_percolate';
     $data = array('doc' => $doc->getData());
     // Add query to filter results after percolation
     if ($query) {
         $query = Query::create($query);
         $data['query'] = $query->getQuery();
     }
     $response = $this->getIndex()->getClient()->request($path, Request::GET, $data);
     $data = $response->getData();
     return $data['matches'];
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:Percolator.php

示例3: testOrderBy

 function testOrderBy()
 {
     $q = Query::create('test_table')->addOrder('fun ASC')->addOrder('good', Query::DESC);
     $order_clause = $q->__toString();
     $this->assertEquals("SELECT `test_table`.*\nFROM `test_table`\nORDER BY `fun` ASC, `good` DESC", $order_clause);
 }
开发者ID:abcarroll,项目名称:DABL,代码行数:6,代码来源:QueryTest.php

示例4: prepare

 /**
  * @inheritdoc
  */
 public function prepare($builder)
 {
     // NOTE: because the same ActiveQuery may be used to build different SQL statements
     // (e.g. by ActiveDataProvider, one for count query, the other for row data query,
     // it is important to make sure the same ActiveQuery can be used to build SQL statements
     // multiple times.
     if (!empty($this->joinWith)) {
         $this->buildJoinWith();
         $this->joinWith = null;
         // clean it up to avoid issue https://github.com/yiisoft/yii2/issues/2687
     }
     if (empty($this->from)) {
         /* @var $modelClass ActiveRecord */
         // 如果没有设置 from,就认为是 ActiveRecord 使用的
         $modelClass = $this->modelClass;
         // 取出表名,放入到 from 中
         $tableName = $modelClass::tableName();
         $this->from = [$tableName];
     }
     if (empty($this->select) && !empty($this->join)) {
         // 如果没有定义 select 并且定义了 join
         // 遍历 from,假设其值为 ['cat' => 'category', 'user']
         foreach ((array) $this->from as $alias => $table) {
             if (is_string($alias)) {
                 // 如果索引是字符串,就表示 $alias 是相应的简称
                 // 所以需要将其对应的表的字段(即 "$alias.*") 放入到 select 中
                 $this->select = ["{$alias}.*"];
             } elseif (is_string($table)) {
                 if (preg_match('/^(.*?)\\s+({{\\w+}}|\\w+)$/', $table, $matches)) {
                     // 支持 $table 是 'category cat' 的形式,这样会匹配出 cat 简称
                     $alias = $matches[2];
                 } else {
                     // 不匹配,直接使用表名
                     $alias = $table;
                 }
                 $this->select = ["{$alias}.*"];
             }
             break;
         }
     }
     if ($this->primaryModel === null) {
         // eager loading
         // 立即加载
         $query = Query::create($this);
     } else {
         // lazy loading of a relation
         // 延迟加载
         $where = $this->where;
         if ($this->via instanceof self) {
             // via junction table
             $viaModels = $this->via->findJunctionRows([$this->primaryModel]);
             $this->filterByModels($viaModels);
         } elseif (is_array($this->via)) {
             // via relation
             /* @var $viaQuery ActiveQuery */
             list($viaName, $viaQuery) = $this->via;
             if ($viaQuery->multiple) {
                 $viaModels = $viaQuery->all();
                 $this->primaryModel->populateRelation($viaName, $viaModels);
             } else {
                 $model = $viaQuery->one();
                 $this->primaryModel->populateRelation($viaName, $model);
                 $viaModels = $model === null ? [] : [$model];
             }
             $this->filterByModels($viaModels);
         } else {
             $this->filterByModels([$this->primaryModel]);
         }
         $query = Query::create($this);
         $this->where = $where;
     }
     if (!empty($this->on)) {
         $query->andWhere($this->on);
     }
     return $query;
 }
开发者ID:glcode,项目名称:yii2-2.0.3-annotated,代码行数:79,代码来源:ActiveQuery.php

示例5: createAggregateChild

 /**
  * Add the cypher clause to build the relationship and the node corresponding
  * to a child of the aggregate
  *
  * @param ValueObject $meta
  * @param Str $nodeName
  * @param CollectionInterface $data
  * @param Query $query
  *
  * @return Query
  */
 private function createAggregateChild(ValueObject $meta, Str $nodeName, CollectionInterface $data, Query $query) : Query
 {
     $relationshipName = $nodeName->append('_')->append($meta->relationship()->property());
     $endNodeName = $relationshipName->append('_')->append($meta->relationship()->childProperty());
     $endNodeProperties = $this->buildProperties($meta->properties(), $endNodeParamKey = $endNodeName->append('_props'));
     $relationshipProperties = $this->buildProperties($meta->relationship()->properties(), $relationshipParamKey = $relationshipName->append('_props'));
     return $query->create((string) $nodeName)->linkedTo((string) $endNodeName, $meta->labels()->toPrimitive())->withProperties($endNodeProperties->toPrimitive())->withParameters([(string) $endNodeParamKey => $data->get($meta->relationship()->childProperty())->toPrimitive()])->through((string) $meta->relationship()->type(), (string) $relationshipName, DBALRelationship::LEFT)->withProperties($relationshipProperties->toPrimitive())->withParameters([(string) $relationshipParamKey => $data->unset($meta->relationship()->childProperty())->toPrimitive()]);
 }
开发者ID:innmind,项目名称:neo4j-onm,代码行数:19,代码来源:InsertPersister.php

示例6: prepare

 /**
  * @inheritdoc
  */
 public function prepare($builder)
 {
     // NOTE: because the same ActiveQuery may be used to build different SQL statements
     // (e.g. by ActiveDataProvider, one for count query, the other for row data query,
     // it is important to make sure the same ActiveQuery can be used to build SQL statements
     // multiple times.
     if (!empty($this->joinWith)) {
         $this->buildJoinWith();
         $this->joinWith = null;
         // clean it up to avoid issue https://github.com/yiisoft/yii2/issues/2687
     }
     if (empty($this->from)) {
         /* @var $modelClass ActiveRecord */
         $modelClass = $this->modelClass;
         $tableName = $modelClass::tableName();
         $this->from = [$tableName];
     }
     if (empty($this->select) && !empty($this->join)) {
         foreach ((array) $this->from as $alias => $table) {
             if (is_string($alias)) {
                 $this->select = ["{$alias}.*"];
             } elseif (is_string($table)) {
                 if (preg_match('/^(.*?)\\s+({{\\w+}}|\\w+)$/', $table, $matches)) {
                     $alias = $matches[2];
                 } else {
                     $alias = $table;
                 }
                 $this->select = ["{$alias}.*"];
             }
             break;
         }
     }
     if ($this->primaryModel === null) {
         // eager loading
         $query = Query::create($this);
     } else {
         // lazy loading of a relation
         $where = $this->where;
         if ($this->via instanceof self) {
             // via pivot table
             $viaModels = $this->via->findPivotRows([$this->primaryModel]);
             $this->filterByModels($viaModels);
         } elseif (is_array($this->via)) {
             // via relation
             /* @var $viaQuery ActiveQuery */
             list($viaName, $viaQuery) = $this->via;
             if ($viaQuery->multiple) {
                 $viaModels = $viaQuery->all();
                 $this->primaryModel->populateRelation($viaName, $viaModels);
             } else {
                 $model = $viaQuery->one();
                 $this->primaryModel->populateRelation($viaName, $model);
                 $viaModels = $model === null ? [] : [$model];
             }
             $this->filterByModels($viaModels);
         } else {
             $this->filterByModels([$this->primaryModel]);
         }
         $query = Query::create($this);
         $this->where = $where;
     }
     if (!empty($this->on)) {
         $query->andWhere($this->on);
     }
     return $query;
 }
开发者ID:aivavic,项目名称:yii2,代码行数:69,代码来源:ActiveQuery.php

示例7: _percolate

 /**
  * @param string                                               $path
  * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query] $query  [description]
  * @param array                                                $data
  * @param array                                                $params
  *
  * @return array
  */
 protected function _percolate($path, $query, $data = array(), $params = array())
 {
     // Add query to filter the percolator queries which are executed.
     if ($query) {
         $query = Query::create($query);
         $data['query'] = $query->getQuery()->toArray();
     }
     $response = $this->getIndex()->getClient()->request($path, Request::GET, $data, $params);
     $data = $response->getData();
     if (isset($data['matches'])) {
         return $data['matches'];
     }
     return array();
 }
开发者ID:nadeem-khan,项目名称:Elastica,代码行数:22,代码来源:Percolator.php

示例8: get


//.........这里部分代码省略.........
         $paramarray = Posts::merge_presets($paramarray, $presets);
     }
     // let plugins alter the param array before we use it. could be useful for modifying search results, etc.
     $paramarray = Plugins::filter('posts_get_paramarray', $paramarray);
     $join_params = array();
     $params = array();
     $fns = array('get_results', 'get_row', 'get_value', 'get_query');
     $select_ary = array();
     // Default fields to select, everything by default
     $default_fields = Plugins::filter('post_default_fields', Post::default_fields(), $paramarray);
     if (isset($paramarray['default_fields'])) {
         $param_defaults = Utils::single_array($paramarray['default_fields']);
         $default_fields = array_merge($default_fields, $param_defaults);
     }
     foreach ($default_fields as $field => $value) {
         if (preg_match('/(?:(?P<table>[\\w\\{\\}]+)\\.)?(?P<field>\\w+)(?:(?:\\s+as\\s+)(?P<alias>\\w+))?/i', $field, $fielddata)) {
             if (empty($fielddata['table'])) {
                 $fielddata['table'] = '{posts}';
             }
             if (empty($fielddata['alias'])) {
                 $fielddata['alias'] = $fielddata['field'];
             }
         }
         $select_ary[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']} AS {$fielddata['alias']}";
         $select_distinct[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']}";
     }
     // Define the WHERE sets to process and OR in the final SQL statement
     if (isset($paramarray['where']) && is_array($paramarray['where'])) {
         $wheresets = $paramarray['where'];
     } else {
         $wheresets = array(array());
     }
     /* Start building the WHERE clauses */
     $query = Query::create('{posts}');
     $query->select($select_ary);
     // If the request has a textual WHERE clause, add it to the query then continue the processing of the $wheresets
     if (isset($paramarray['where']) && is_string($paramarray['where'])) {
         $query->where()->add($paramarray['where']);
     }
     foreach ($wheresets as $paramset) {
         $where = new QueryWhere();
         $paramset = array_merge((array) $paramarray, (array) $paramset);
         if (isset($paramset['id'])) {
             $where->in('{posts}.id', $paramset['id'], 'posts_id', 'intval');
         }
         if (isset($paramset['not:id'])) {
             $where->in('{posts}.id', $paramset['not:id'], 'posts_not_id', 'intval', false);
         }
         if (isset($paramset['status']) && !self::empty_param($paramset['status'])) {
             $where->in('{posts}.status', $paramset['status'], 'posts_status', function ($a) {
                 return Post::status($a);
             });
         }
         if (isset($paramset['not:status']) && !self::empty_param($paramset['not:status'])) {
             $where->in('{posts}.status', $paramset['not:status'], 'posts_not_status', function ($a) {
                 return Post::status($a);
             }, null, false);
         }
         if (isset($paramset['content_type']) && !self::empty_param($paramset['content_type'])) {
             $where->in('{posts}.content_type', $paramset['content_type'], 'posts_content_type', function ($a) {
                 return Post::type($a);
             });
         }
         if (isset($paramset['not:content_type'])) {
             $where->in('{posts}.content_type', $paramset['not:content_type'], 'posts_not_content_type', function ($a) {
                 return Post::type($a);
开发者ID:habari,项目名称:system,代码行数:67,代码来源:posts.php

示例9: get

 /**
  * Returns a LogEntry or EventLog array based on supplied parameters.
  * By default,fetch as many entries as pagination allows and order them in a descending fashion based on timestamp.
  *
  * @todo Cache query results.
  * @param array $paramarray An associated array of parameters, or a querystring
  * The following keys are supported:
  * - id => an entry id or array of post ids
  * - user_id => id of the logged in user for which to return entries
  * - severity => severity level for which to return entries
  * - type_id => the numeric id or array of ids for the type of entries for which which to return entries
  * - module => a name or array of names of modules for which to return entries
  * - type => a single type name or array of type names for which to return entries
  * - ip => the IP number for which to return entries
  * - criteria => a literal search string to match entry message content or a special search
  * - day => a day of entry creation, ignored if month and year are not specified
  * - month => a month of entry creation, ignored if year isn't specified
  * - year => a year of entry creation
  * - orderby => how to order the returned entries
  * - fetch_fn => the function used to fetch data, one of 'get_results', 'get_row', 'get_value'
  * - count => return the number of entries that would be returned by this request
  * - month_cts => return the number of entries created in each month
  * - nolimit => do not implicitly set limit
  * - limit => the maximum number of entries to return, implicitly set for many queries
  * - index => 
  * - offset => amount by which to offset returned entries, used in conjunction with limit
  * - where => manipulate the generated WHERE clause
  * - return_data => set to return the data associated with the entry
  * 
  * @return array An array of LogEntry objects, or a single LogEntry object, depending on request
  */
 public static function get($paramarray = array())
 {
     $params = array();
     $fns = array('get_results', 'get_row', 'get_value');
     $select_ary = array();
     $select_distinct = array();
     // Put incoming parameters into the local scope
     $paramarray = Utils::get_params($paramarray);
     if ($paramarray instanceof \ArrayIterator) {
         $paramarray = $paramarray->getArrayCopy();
     }
     $select_fields = LogEntry::default_fields();
     if (!isset($paramarray['return_data'])) {
         unset($select_fields['data']);
     }
     foreach ($select_fields as $field => $value) {
         if (preg_match('/(?:(?P<table>[\\w\\{\\}]+)\\.)?(?P<field>\\w+)(?:(?:\\s+as\\s+)(?P<alias>\\w+))?/i', $field, $fielddata)) {
             if (empty($fielddata['table'])) {
                 $fielddata['table'] = '{log}';
             }
             if (empty($fielddata['alias'])) {
                 $fielddata['alias'] = $fielddata['field'];
             }
         }
         $select_ary[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']} AS {$fielddata['alias']}";
         $select_distinct[$fielddata['alias']] = "{$fielddata['table']}.{$fielddata['field']}";
     }
     // Transact on possible multiple sets of where information that is to be OR'ed
     if (isset($paramarray['where']) && is_array($paramarray['where'])) {
         $wheresets = $paramarray['where'];
     } else {
         $wheresets = array(array());
     }
     $query = Query::create('{log}');
     $query->select($select_ary);
     if (isset($paramarray['where']) && is_string($paramarray['where'])) {
         $query->where()->add($paramarray['where']);
     }
     foreach ($wheresets as $paramset) {
         $where = new QueryWhere();
         $paramset = array_merge((array) $paramarray, (array) $paramset);
         if (isset($paramset['id'])) {
             $where->in('{log}.id', $paramset['id'], 'log_id', 'intval');
         }
         if (isset($paramset['user_id'])) {
             $where->in('{log}.user_id', $paramset['user_id'], 'log_user_id', 'intval');
         }
         if (isset($paramset['severity']) && 'any' != LogEntry::severity_name($paramset['severity'])) {
             $where->in('{log}.severity_id', $paramset['severity'], 'log_severity_id', function ($a) {
                 return LogEntry::severity($a);
             });
         }
         if (isset($paramset['type_id'])) {
             $where->in('{log}.type_id', $paramset['type_id'], 'log_type_id', 'intval');
         }
         if (isset($paramset['module'])) {
             $paramset['module'] = Utils::single_array($paramset['module']);
             $qry = Query::create('{log_types}');
             $qry->select('{log_types}.id')->distinct();
             $qry->where()->in('{log_types}.module', $paramset['module'], 'log_subquery_module');
             $where->in('{log}.type_id', $qry, 'log_module');
         }
         if (isset($paramset['type'])) {
             $paramset['type'] = Utils::single_array($paramset['type']);
             $qry = Query::create('{log_types}');
             $qry->select('{log_types}.id')->distinct();
             $qry->where()->in('{log_types}.type', $paramset['type'], 'log_subquery_type');
             $where->in('{log}.type_id', $qry, 'log_type');
         }
//.........这里部分代码省略.........
开发者ID:habari,项目名称:system,代码行数:101,代码来源:eventlog.php

示例10: get_tree

 /**
  * Retrieve the vocabulary
  * @return Terms The Term objects in the vocabulary, in tree order
  **/
 public function get_tree($orderby = 'mptt_left ASC')
 {
     $query = Query::create('{terms}')->select('{terms}.*');
     $query->where()->in('vocabulary_id', $this->id);
     // If the vocabulary is unique, save the extra mess of queries and fetch the object data, too
     if (in_array('unique', $this->features)) {
         $query->join('LEFT JOIN {object_terms} on {object_terms}.term_id = {terms}.id', array(), 'object_terms');
         $query->join('LEFT JOIN {object_types} on {object_types}.id = {object_terms}.object_type_id', array(), 'object_types');
         $query->select('{object_terms}.object_id');
         $query->select('{object_types}.name AS type');
     }
     $query->orderby($orderby);
     return new Terms($query->results('Term'));
 }
开发者ID:habari,项目名称:system,代码行数:18,代码来源:vocabulary.php

示例11: Status

addInputTxt('emai', 'col-sm-2', 'E-mail');
addButton('btn btn-success', 'Submit', 'col-sm-offset-2 col-sm-4', 'Sign Up');
?>
                    </fieldset>
        </form>  
                    <?php 
require_once 'Status.php';
require_once 'database.php';
$q = new Status($db);
$q->viewStatus('dvd', 'available', 'Return');
?>
                    <?php 
require_once "Query.php";
$crud_book = new Query(7, 'dvd', 'item_no,title,genre,description,price,rental_period,status');
$crud_book->mysqlConnect('localhost', 'root', '', 'video_rental');
$crud_book->create();
echo "<hr/>";
$crud_book->read();
echo "<hr/>";
$crud_book->update();
echo "<hr/>";
$crud_book->delete();
echo "<hr/>";
?>

                </div>
            </div>
        </div>
       
    </body>
</html>
开发者ID:jayp3e011,项目名称:Planas-Bautista_Finals,代码行数:31,代码来源:test2.php

示例12: array

	function order_view ($instance, $direction, &$context) {
		
		// Current ordering value
		$pos_name = $this->custom_position;
		$pos = $instance->$pos_name;
		
		// Setup query params
		$params = array($pos);
		
		$tree_field = $this->get_tree_field();
		$tree_field_filter = '';
		if ($tree_field) {
			$v = $instance->{$tree_field->name};
			$tree_field_filter = sprintf('AND %s %s %%s', escape($tree_field->name), is_null($v) ? 'IS' : '=');
			$params[] = $v;
		}
		
		// Create a raw query to get the item which will be swapped by this instance
		// Moving up:
			// look for a directly lower value, use descending order to get the closest value
		// Moving down:
			// look for a directly greater value, use ascending order to get the closest value
			// SELECT * FROM gm_cms_page WHERE pos >|< %d ORDER BY pos DESC|ASC LIMIT 1
		$sql = sprintf('SELECT * FROM %1$s WHERE %2$s %4$s %%d %5$s ORDER BY %2$s %3$s LIMIT 1',
			$this->meta->table_safe,
			escape($pos_name),
			($direction == 'up') ? 'DESC' : 'ASC',
			($direction == 'up') ? '<' : '>',
			$tree_field_filter
		);
		
		// Create a query instance
		$q = new Query($this->meta);
		// Execute and fetch the raw query
		$data = $q->sql($sql, $params);
		
		// Check for data
		if ($data) {
			
			// Data is an array of one row
			// Create an instance based on the first row
			$next = $q->create($data[0], false);
			
			// Swap position values
			$instance->$pos_name = $next->$pos_name;
			$next->$pos_name = $pos;
			
			// Save
			$instance->save();
			$next->save();
			
		}
		
		if ($_SERVER['HTTP_REFERER']) {
			redir($_SERVER['HTTP_REFERER']);
		}
		else {
			redir('../../../');
		}
	}
开发者ID:ricobl,项目名称:frix,代码行数:60,代码来源:AdminOptions.php

示例13: query

 public static function query()
 {
     return Query::create()->from(get_called_class());
 }
开发者ID:snoopckuu,项目名称:Document-Oriented-DB-ORM,代码行数:4,代码来源:Resource.php

示例14: dirname

<?php

namespace Evolution7\SocialApi\Resources\example;

use Evolution7\SocialApi\Service\ServiceFactory;
use Evolution7\SocialApi\Token\AccessToken;
require_once dirname(dirname(dirname(dirname(__DIR__)))) . '/vendor/autoload.php';
session_start();
// Example configuration
require_once 'config.php';
// Check if user authenticated
if (!array_key_exists('access_token', $_SESSION)) {
    // Authenticate
    header('Location: authentication.php');
    exit;
}
// Get service
$service = ServiceFactory::get($config);
// Create access token instance
$accessToken = new AccessToken($_SESSION['access_token']['token'], $_SESSION['access_token']['secret']);
// Build search query
$query = Query::create()->filterByHashtag('#worldcup')->filterImages();
// Make API request
try {
    $result = $service->search($query);
} catch (\Exception $e) {
    $result = $e->getMessage();
}
// Output result
var_dump($result);
开发者ID:jenalgit,项目名称:social-api,代码行数:30,代码来源:search.php

示例15: registerQuery

 /**
  * Registers a percolator query
  *
  * @param  string                                             $name  Query name
  * @param  string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to add
  * @return \Elastica\Response
  */
 public function registerQuery($name, $query)
 {
     $path = '_percolator/' . $this->_index->getName() . '/' . $name;
     $query = Query::create($query);
     return $this->_index->getClient()->request($path, Request::PUT, $query->toArray());
 }
开发者ID:kskod,项目名称:Elastica,代码行数:13,代码来源:Percolator.php


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