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


PHP Query::build方法代码示例

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


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

示例1: afterSave

 public function afterSave()
 {
     $query = Query::build()->from('itemTags')->where('item', '=', 'item', true)->bind('item', $this->id)->delete();
     foreach ($this->tagIds as $tag) {
         $query = Query::build()->from('itemTags')->set('item', 'item', true)->set('tag', 'tag', true)->bind('item', $this->id)->bind('tag', $tag)->insert();
     }
 }
开发者ID:amarble,项目名称:project-byz,代码行数:7,代码来源:items.php

示例2: getQuery

 function getQuery(RelationshipLoader $loader)
 {
     //TODO: IF JOINT TABLE DOESNT EXIST, THEN CREATE IT
     if ($loader instanceof DeferredLoader) {
         $joinTable = $this->getJoinTable();
         $query = Query::build(Query::SQL, $loader->Relation->Entity)->select()->from($loader->Relation->Entity)->join($joinTable, $loader->Relation->Association);
         if ($loader->Relation->isLocalReference()) {
             foreach ($this->_joinAttributes as $joinAttribute) {
                 $query->where($joinTable->Attributes[$joinAttribute->Name], $loader->Source->Data[$joinAttribute->ReferencedAttribute]);
             }
         } else {
             foreach ($this->_inverseJoinAttributes as $joinAttribute) {
                 //echo $joinAttribute->Name;
                 //echo "\n";
                 //var_dump( $joinTable );
                 //echo $joinTable->Attributes[$joinAttribute->Name]->InnerName;
                 //$query->where( $joinTable->Attributes[$joinAttribute->Name], $loader->Source->Data[ $joinAttribute->ReferencedAttribute ]);
             }
         }
         //->where( $joinTable->Attributes[$this->_joinColumns->Name]->InnerName, $loader->Source->Data[$loader->Relation->Association->PrimaryKey->OuterName]);
         //echo (string)$query;
     }
     if (isset($query)) {
         return $query;
     }
     return null;
 }
开发者ID:Kinetical,项目名称:Kinesis,代码行数:27,代码来源:JoinTable.php

示例3: taskRun

 /**
  * @mcms_message ru.molinos.cms.cron
  */
 public static function taskRun(Context $ctx)
 {
     $types = $ctx->config->get('modules/subscription/types', array());
     $xsl = $ctx->config->get('modules/subscription/stylesheet', os::path('lib', 'modules', 'subscription', 'message.xsl'));
     $sub = $ctx->config->get('modules/subscription/subject', 'Новости сайта %host');
     if (empty($types)) {
         return;
     }
     $ctx->db->beginTransaction();
     $users = Node::find(array('class' => 'subscription', 'deleted' => 0, 'published' => 1, '#sort' => 'name'), $ctx->db);
     // Обрабатываем активных пользователей.
     foreach ($users as $user) {
         $olast = $last = intval($user->last);
         if ($sections = (array) $user->tags) {
             list($sql, $params) = Query::build(array('class' => $types, 'tags' => $sections, 'published' => 1, 'deleted' => 0, 'id' => array('>' . ($olast + 1))))->getSelect(array('id', 'xml'));
             $nodes = $ctx->db->getResultsKV('id', 'xml', $sql, $params);
             // Отправляем документы.
             foreach ($nodes as $nid => $node) {
                 $xml = html::em('message', array('mode' => 'regular', 'unsubscribe' => 'subscription.rpc?action=remove&name=' . urlencode($user->name) . '&id=' . $user->id, 'base' => $ctx->url()->getBase($ctx), 'host' => MCMS_HOST_NAME), $node);
                 $body = xslt::transform($xml, $xsl, null);
                 $subject = t($sub, array('%host' => $ctx->url()->host()));
                 BebopMimeMail::send(null, $user->name, $subject, $body);
                 $last = max($last, $nid);
             }
             // Запоминаем последнее отправленное сообщение.
             $user->last = $last;
             $user->save();
         }
     }
     $ctx->db->commit();
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:34,代码来源:class.subscriptionscheduler.php

示例4: build

 /**
  * Build the query to a string
  *
  * @return string
  */
 public function build()
 {
     // Some task's like clearing the query parameters
     // are handeld by the parent build function.
     parent::build();
     // Lets run the Builder by passing the current query object
     return $this->handler->builder()->compile_update($this);
 }
开发者ID:clancats,项目名称:core,代码行数:13,代码来源:Update.php

示例5: test

 public function test()
 {
     $pdo = new DummyPDO();
     $orig = "string: :a@string\nint :b@int\nstring: :a@string\nint :b@int";
     $stmt = Query::build($pdo, $orig, [':a' => 'AAAA', ':b' => '2222']);
     $expected = 'string: @AAAA@ int 2222 string: @AAAA@ int 2222';
     $this->assertSame($expected, $stmt->queryString);
 }
开发者ID:BaguettePHP,项目名称:TetoSQL,代码行数:8,代码来源:QueryTest.php

示例6: on_node_xml

 /**
  * Добавляет в XML нод информацию о разделах.
  * @mcms_message ru.molinos.cms.node.xml
  */
 public static function on_node_xml(Node $node)
 {
     list($sql, $params) = Query::build(array('class' => 'tag', 'deleted' => 0, 'tagged' => $node->id))->getSelect(array('id', 'published', 'name', 'class'));
     $data = $node->getDB()->getResults($sql, $params);
     $result = '';
     foreach ($data as $row) {
         $result .= html::em('node', $row);
     }
     return html::wrap('taxonomy', $result);
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:14,代码来源:class.taxonomyapi.php

示例7: query

 /**
  * Queries the google analytics service.
  *
  * @param \Widop\GoogleAnalytics\Query $query The google analytics query.
  *
  * @throws \Widop\GoogleAnalytics\GoogleAnalyticsException If an error occured when querying the google analytics service.
  *
  * @return \Widop\GoogleAnalytics\Response The google analytics response.
  */
 public function query(Query $query)
 {
     $accessToken = $this->getClient()->getAccessToken();
     $uri = $query->build($accessToken);
     $content = $this->getClient()->getHttpAdapter()->getContent($uri);
     $json = json_decode($content, true);
     if (!is_array($json) || isset($json['error'])) {
         throw GoogleAnalyticsException::invalidQuery(isset($json['error']) ? $json['error']['message'] : 'Invalid json');
     }
     return new Response($json);
 }
开发者ID:dominium,项目名称:google-analytics,代码行数:20,代码来源:Service.php

示例8: build

 	/**
 	 * Returns the values + original path as a complete URI
 	 * 
 	 * @param $newvalues
 	 * @param $queryvalues
 	 * @param $removevalues
 	 * @return unknown_type
 	 */
 	function build($newvalues=null, $removevalues=null, $queryvalues=null, $removequeryvalues=null)
 	{ 		
 		$segs=$this->segments;
		
 		// remove any values or key=>value pairs first
 		if ($removevalues!=null)
 			foreach($removevalues as $key=>$value)
 			{
 				$this->remove_value($key, $value);
 			}
 		
  		if ($newvalues!=null)
	 		foreach($newvalues as $key=>$value)
	 		{
 				if (is_array($value))
					foreach ($value as $val)
						$values[] = strtolower($val);
	 			else
	 				$values[] = strtolower($value);
	 				 			
		 		$added=false;

	 			foreach($values as $val) 
 				{	
	 			
					if (is_numeric($key) && count($segs)>=$key)
	 				{   
	 					// allows segment to be added at a specific index (or in front of the current value)
	 					//$segs[]=$value;
						array_splice($segs,$key,0,$val);
	 					$added=true;
	
	 				}
	 				else for($i=0; $i<count($segs); $i++)
		 				if ($segs[$i]==$key)
			 			{
		 					array_splice($segs,$i+1,1,$val);
		 					
		 					$added=true;
		 					break;
		 				}
	 			
		 			if (!$added)
			 			array_splice($segs,count($segs),0,array($key,$val));
 				}
	 		}
	 		
		for($i=0; $i<count($segs); $i++)
			$segs[$i] = rawurlencode($segs[$i]);
		 	
 		return rtrim($this->root."/".implode('/',$segs).$this->query->build($queryvalues,$removequeryvalues), '/');
 	}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:60,代码来源:uri.php

示例9: query

 /**
  * @param Query $query
  * @return Response
  * @throws XitiException
  */
 public function query(Query $query, $clientRequestId = null)
 {
     $headers = $this->getClient()->getHeaders($clientRequestId);
     $uri = $query->build();
     $content = $this->getClient()->getHttpAdapter()->getContent($uri, $headers);
     if (is_object($content)) {
         $content = $content->getBody();
     }
     $json = json_decode($content, true);
     if (!is_array($json) || isset($json['ErrorCode'])) {
         throw XitiException::invalidQuery(isset($json['ErrorCode']) ? $json['ErrorMessage'] : 'Invalid json');
     }
     return new Response($json);
 }
开发者ID:RequestLab,项目名称:xiti-analytics,代码行数:19,代码来源:Service.php

示例10: on_find_xml

 public static function on_find_xml(Context $ctx)
 {
     if (null === ($search = $ctx->get('search'))) {
         throw new BadRequestException(t('Не указана подстрока для поиска (GET-параметр search).'));
     }
     if (!($limit = intval($ctx->get('limit', 5)))) {
         throw new BadRequestException(t('Не указано количество возовращаемых меток (GET-параметр limit).'));
     }
     list($sql, $params) = Query::build(array('class' => 'label', 'deleted' => 0, 'published' => 1, 'name?|' => '%' . $search . '%', '#sort' => 'name'))->getSelect(null, null, 'name');
     $result = '';
     foreach ((array) $ctx->db->getResultsV("name", $sql, $params) as $name) {
         $result .= html::em('label', html::cdata($name));
     }
     return new Response(html::em('labels', array('search' => $search, 'limit' => $limit), $result), 'text/xml');
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:15,代码来源:class.labelsapi.php

示例11: getQuery

 function getQuery(RelationshipLoader $loader)
 {
     if ($loader instanceof DeferredLoader) {
         if ($loader->Relation->inversedBy !== null) {
             $keyColumn = $loader->Relation->inversedBy;
         } else {
             $keyColumn = $loader->Relation->Entity->PrimaryKey->InnerName;
         }
         $query = Query::build(Query::SQL, Query::HYDRATE_SCALAR)->select()->from($loader->Relation->Entity)->where($keyColumn, $loader->Source->Data[$this->Name]);
         $query->DataType = $loader->Relation->Entity->InnerName;
         return $query;
     } elseif ($loader instanceof ImmediateLoader) {
         // JOIN
     }
     return null;
 }
开发者ID:Kinetical,项目名称:Kinesis,代码行数:16,代码来源:JoinColumn.php

示例12: query

 /**
  * @param Query $query
  * @return Response
  * @throws EstatException
  */
 public function query(Query $query)
 {
     $tokenId = $this->getClient()->getAccessToken();
     $uri = Query::URL;
     $headers = array('Content-Type' => 'application/json');
     $content = $query->build($tokenId);
     $content = $this->getClient()->getHttpAdapter()->postContent($uri, $headers, $content);
     if ($content === null) {
         throw EstatException::invalidResponse('No content');
     }
     $json = json_decode($content, true);
     if (!is_array($json) || isset($json['gosuResponse']['errorCode'])) {
         throw EstatException::invalidQuery(isset($json['gosuResponse']['errorCode']) ? $json['gosuResponse']['errorMessage'] : 'Invalid json');
     }
     return new Response($json);
 }
开发者ID:requestlab,项目名称:estat,代码行数:21,代码来源:Service.php

示例13: write_nodes

 private static function write_nodes(Context $ctx, $f)
 {
     $filter = array('class' => $ctx->db->getResultsV("name", "SELECT `name` FROM `node` WHERE `class` = 'type' AND `deleted` = 0 AND `published` = 1"), 'published' => 1, 'deleted' => 0, '#sort' => '-id');
     list($sql, $params) = Query::build($filter)->getSelect(array('id', 'updated'));
     if ($nodes = $ctx->db->getResults($sql, $params)) {
         fwrite($f, "<!-- documents -->\n");
         foreach ($nodes as $node) {
             $line = "<url>" . "<loc>http://" . MCMS_HOST_NAME . "/node/{$node['id']}</loc>";
             if (!empty($node['updated'])) {
                 $date = gmdate('c', strtotime($node['updated']));
                 $line .= "<lastmod>{$date}</lastmod>";
             }
             $line .= "</url>\n";
             fwrite($f, $line);
         }
     }
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:17,代码来源:class.sitemap.php

示例14: on_format_text

 /**
  * Обработка ссылок в формате [[текст]].
  * @mcms_message ru.molinos.cms.format.text
  */
 public static function on_format_text(Context $ctx, $fieldName, &$text)
 {
     if ($map = self::map($text)) {
         $names = array();
         foreach ($map as $v) {
             $names[] = $v[0];
         }
         list($sql, $params) = Query::build(array('class' => array('story', 'label'), 'published' => 1, 'deleted' => 0, 'name' => $names))->getSelect(array("id", "name"));
         $data = (array) $ctx->db->getResultsKV("name", "id", $sql, $params);
         $replacement = array();
         foreach ($map as $k => $v) {
             $link = $v[1];
             if (isset($data[$v[0]])) {
                 $link = t("<a href='@url'>%text</a>", array('@url' => 'node/' . $data[$v[0]], '%text' => $v[1]));
             }
             $replacement[$k] = $link;
         }
         $text = str_replace(array_keys($replacement), array_values($replacement), $text);
     }
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:24,代码来源:class.linkwikifier.php

示例15: setColumns

 public function setColumns($columns)
 {
     if (!is_array($columns)) {
         $columns = explode(',', $columns);
     }
     $query = Query::build()->from('userColumns')->where('user', '=', 'user', true)->bind('user', $this->id)->delete();
     foreach ($columns as $column) {
         $column = trim($column);
         $query = Query::build()->from('userColumns')->set('user', 'user', true)->set('column', 'column', true)->bind('user', $this->id)->bind('column', $column)->insert();
     }
 }
开发者ID:amarble,项目名称:project-byz,代码行数:11,代码来源:users.php


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