本文整理汇总了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();
}
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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), '/');
}
示例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);
}
示例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');
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
}