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


PHP Query::join方法代码示例

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


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

示例1: testSubqueyInJoin

 /**
  * Tests that it is possible to use a subquery in a join clause
  *
  * @return void
  */
 public function testSubqueyInJoin()
 {
     $subquery = (new Query($this->connection))->select('*')->from('authors');
     $query = new Query($this->connection);
     $result = $query->select(['title', 'name'])->from('articles')->join(['b' => $subquery])->execute();
     $this->assertCount(self::ARTICLE_COUNT * self::AUTHOR_COUNT, $result, 'Cross join causes multiplication');
     $subquery->where(['id' => 1]);
     $result = $query->execute();
     $this->assertCount(3, $result);
     $query->join(['b' => ['table' => $subquery, 'conditions' => ['b.id = articles.id']]], [], true);
     $result = $query->execute();
     $this->assertCount(1, $result);
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:18,代码来源:QueryTest.php

示例2: _quoteParts

 /**
  * Quotes all identifiers in each of the clauses of a query
  *
  * @param \Cake\Database\Query $query The query to quote.
  * @return void
  */
 protected function _quoteParts($query)
 {
     foreach (['distinct', 'select', 'from', 'group'] as $part) {
         $contents = $query->clause($part);
         if (!is_array($contents)) {
             continue;
         }
         $result = $this->_basicQuoter($contents);
         if (!empty($result)) {
             $query->{$part}($result, true);
         }
     }
     $joins = $query->clause('join');
     if ($joins) {
         $joins = $this->_quoteJoins($joins);
         $query->join($joins, [], true);
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:24,代码来源:IdentifierQuoter.php

示例3: beforeFind

 public function beforeFind(Event $event, Query $query, ArrayObject $options)
 {
     $query->join(['table' => 'pessoas_associacoes', 'alias' => 'PessoasAssociacoes', 'type' => 'INNER', 'conditions' => ['PessoasAssociacoes.pessoa_id = ' . $this->aliasField('pessoa_id'), 'PessoasAssociacoes.tipo_associacao' => 7, 'PessoasAssociacoes.status !=' => 9]]);
     $query->group($this->aliasField('pessoa_id'));
 }
开发者ID:lucasnpinheiro,项目名称:Kiterp,代码行数:5,代码来源:UsuariosTable.php

示例4: testRemoveJoin

 /**
  * Test removeJoin().
  *
  * @return void
  */
 public function testRemoveJoin()
 {
     $query = new Query($this->connection);
     $query->select(['id', 'title'])->from('articles')->join(['authors' => ['type' => 'INNER', 'conditions' => ['articles.author_id = authors.id']]]);
     $this->assertArrayHasKey('authors', $query->join());
     $this->assertSame($query, $query->removeJoin('authors'));
     $this->assertArrayNotHasKey('authors', $query->join());
 }
开发者ID:mhd94,项目名称:cakephp,代码行数:13,代码来源:QueryTest.php


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