當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。