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


PHP QQ::Count方法代码示例

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


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

示例1: testGroupBy

 public function testGroupBy()
 {
     $objItems = Project::QueryArray(QQ::All(), QQ::Clause(QQ::GroupBy(QQN::Project()->Id), QQ::Count(QQN::Project()->PersonAsTeamMember->PersonId, 'team_member_count')));
     $this->assertEqual(sizeof($objItems), 4, "4 projects found");
     $this->assertEqual($objItems[0]->Name, "ACME Website Redesign", "Project " . $objItems[0]->Name . " found");
     $this->assertEqual($objItems[0]->GetVirtualAttribute('team_member_count'), 5, "5 team members found for project " . $objItems[0]->Name);
     $this->assertEqual($objItems[1]->Name, "State College HR System", "Project " . $objItems[1]->Name . " found");
     $this->assertEqual($objItems[1]->GetVirtualAttribute('team_member_count'), 6, "6 team members found for project " . $objItems[1]->Name);
     $this->assertEqual($objItems[2]->Name, "Blueman Industrial Site Architecture", "Project " . $objItems[2]->Name . " found");
     $this->assertEqual($objItems[2]->GetVirtualAttribute('team_member_count'), 5, "5 team members found for project " . $objItems[2]->Name);
 }
开发者ID:eliud254,项目名称:q-auction,代码行数:11,代码来源:BasicOrmTests.php

示例2: testHaving

 public function testHaving()
 {
     $objItems = Project::QueryArray(QQ::All(), QQ::Clause(QQ::GroupBy(QQN::Project()->Id), QQ::Count(QQN::Project()->PersonAsTeamMember->PersonId, 'team_member_count'), QQ::Having(QQ::SubSql('COUNT({1}) > 5', QQN::Project()->PersonAsTeamMember->PersonId)), QQ::OrderBy(QQN::Project()->Id)));
     $this->assertEqual(sizeof($objItems), 2, "2 projects found");
     $this->assertEqual($objItems[0]->Name, "State College HR System", "Project " . $objItems[0]->Name . " found");
     $this->assertEqual($objItems[0]->GetVirtualAttribute('team_member_count'), 6, "6 team members found for project " . $objItems[0]->Name);
 }
开发者ID:tomVertuoz,项目名称:framework,代码行数:7,代码来源:BasicOrmTests.php

示例3: _p

    _p('<li>' . $objPerson->FirstName . ' ' . $objPerson->LastName . '</li>', false);
}
?>
	</ul>
	<h2>Select all Projects and the Count of Team Members (if applicable)</h2>
	<p><em>GROUP BY in action</em></p>
	<ul>
<?php 
$objProjectArray = Project::QueryArray(QQ::All(), QQ::Clause(QQ::GroupBy(QQN::Project()->Id), QQ::Count(QQN::Project()->PersonAsTeamMember->PersonId, 'team_member_count')));
foreach ($objProjectArray as $objProject) {
    _p('<li>' . $objProject->Name . ' (' . $objProject->GetVirtualAttribute('team_member_count') . ' team members)' . '</li>', false);
}
?>
	</ul>

	<h2>Select all Projects with more than 5 team members. </h2>
	<p><em>Using a Having clause to further limit group functions</em></p>
	<ul>
<?php 
$objProjectArray = Project::QueryArray(QQ::All(), QQ::Clause(QQ::GroupBy(QQN::Project()->Id), QQ::Count(QQN::Project()->PersonAsTeamMember->PersonId, 'team_member_count'), QQ::Having(QQ::SubSql('COUNT({1}) > 5', QQN::Project()->PersonAsTeamMember->PersonId))));
foreach ($objProjectArray as $objProject) {
    _p($objProject->Name . ' (' . $objProject->GetVirtualAttribute('team_member_count') . ' team members)');
    _p('<br/>', false);
}
?>
	</ul>
</div>


<?php 
require '../includes/footer.inc.php';
开发者ID:tomVertuoz,项目名称:framework,代码行数:31,代码来源:qqclause.php

示例4: testSubSql

 public function testSubSql()
 {
     $objProject = Project::QuerySingle(QQ::All(), QQ::Clause(QQ::Count(QQ::SubSql('DISTINCT {1}', QQN::Project()->ManagerPersonId), "manager_count")));
     $this->assertEquals(3, $objProject->GetVirtualAttribute("manager_count"), "Project manager count is 3");
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:5,代码来源:BasicOrmTest.php

示例5: dtgLanguage_Bind

 public function dtgLanguage_Bind()
 {
     if ($this->txtSearch->Text != '') {
         $objSearchCondition = QQ::Like(QQN::NarroLanguage()->LanguageName, sprintf('%%%s%%', $this->txtSearch->Text));
     } else {
         $objSearchCondition = QQ::All();
     }
     switch ($this->lstFilter->SelectedValue) {
         /**
          * Only active
          */
         case 1:
             $objFilterCondition = QQ::AndCondition($objSearchCondition, QQ::Equal(QQN::NarroLanguage()->Active, 1));
             break;
             /**
              * 0 - show all
              */
         /**
          * 0 - show all
          */
         default:
             $objFilterCondition = $objSearchCondition;
     }
     // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll()
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     $this->dtgLanguage->TotalItemCount = NarroLanguage::QueryCount($objFilterCondition);
     // Setup the $objClauses Array
     $objClauses = array(QQ::Expand(QQ::Virtual('last_translation', QQ::SubSql('SELECT MAX(created) FROM narro_suggestion WHERE language_id={1}', QQN::NarroLanguage()->LanguageId))), QQ::Count(QQN::NarroLanguage()->NarroSuggestionAsLanguage->SuggestionId, 'translations_count'), QQ::GroupBy(QQN::NarroLanguage()->LanguageId));
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->dtgLanguage->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->dtgLanguage->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be the array of all NarroLanguage objects, given the clauses above
     $this->dtgLanguage->DataSource = NarroLanguage::QueryArray($objFilterCondition, $objClauses);
     QApplication::ExecuteJavaScript('highlight_datagrid();');
 }
开发者ID:Jobava,项目名称:narro,代码行数:41,代码来源:NarroLanguageListPanel.class.php

示例6: foreach

$objPersonArray = Person::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName);
    _p('<br/>', false);
}
?>



	<h3>Select all People, Ordered by Last Name then First Name, Limited to the first 4 results</h3>
<?php 
$objPersonArray = Person::QueryArray(QQ::All(), QQ::Clause(QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName), QQ::LimitInfo(4)));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName);
    _p('<br/>', false);
}
?>



	<h3>Select all Projects and the Count of Team Members (if applicable)</h3>
<?php 
$objProjectArray = Project::QueryArray(QQ::All(), QQ::Clause(QQ::GroupBy(QQN::Project()->Id), QQ::Count(QQN::Project()->PersonAsTeamMember->PersonId, 'team_member_count')));
foreach ($objProjectArray as $objProject) {
    _p($objProject->Name . ' (' . $objProject->GetVirtualAttribute('team_member_count') . ' team members)');
    _p('<br/>', false);
}
?>

<?php 
require __INCLUDES__ . '/examples/footer.inc.php';
开发者ID:qcodo,项目名称:qcodo,代码行数:31,代码来源:qqclause.php

示例7: __construct

 public function __construct($strDate, $objParentObject, NarroProject $objProject = null, $strControlId = null)
 {
     // Call the Parent
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     $this->strTemplate = dirname(__FILE__) . '/' . __CLASS__ . '.tpl.php';
     $this->blnAutoRenderChildren = true;
     // Tabs
     $this->tabTop = new QTabs($this);
     $pnlTranslators = new NarroUserDataGrid($this->tabTop);
     $pnlTranslators->CssClass = 'datagrid';
     $colUsername = $pnlTranslators->MetaAddColumn(QQN::NarroUser()->Username);
     $colUsername->HtmlEntities = false;
     $colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
     $colCnt = new QDataGridColumn(t('Translations'));
     $colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
     $pnlTranslators->SortColumnIndex = 1;
     $pnlTranslators->ShowHeader = false;
     $pnlTranslators->SortDirection = 1;
     $pnlTranslators->AddColumn($colCnt);
     $pnlTranslators->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroSuggestionAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroSuggestionAsUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroSuggestionAsUser->Text->NarroContextAsText->ProjectId, $objProject->ProjectId) : QQ::All());
     $pnlTranslators->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroSuggestionAsUser->SuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
     $pnlReviewers = new NarroUserDataGrid($this->tabTop);
     $pnlReviewers->CssClass = 'datagrid';
     $colUsername = $pnlReviewers->MetaAddColumn(QQN::NarroUser()->Username);
     $colUsername->HtmlEntities = false;
     $colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
     $colCnt = new QDataGridColumn(t('Reviewers'));
     $colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
     $pnlReviewers->SortColumnIndex = 1;
     $pnlReviewers->ShowHeader = false;
     $pnlReviewers->SortDirection = 1;
     $pnlReviewers->AddColumn($colCnt);
     $pnlReviewers->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroContextInfoAsValidatorUser->Modified, $strDate), QQ::Equal(QQN::NarroUser()->NarroContextInfoAsValidatorUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroContextInfoAsValidatorUser->Context->ProjectId, $objProject->ProjectId) : QQ::All());
     $pnlReviewers->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroContextInfoAsValidatorUser->ValidSuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
     $pnlVoters = new NarroUserDataGrid($this->tabTop);
     $pnlVoters->CssClass = 'datagrid';
     $colUsername = $pnlVoters->MetaAddColumn(QQN::NarroUser()->Username);
     $colUsername->HtmlEntities = false;
     $colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
     $colCnt = new QDataGridColumn(t('Reviewers'));
     $colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
     $pnlVoters->SortColumnIndex = 1;
     $pnlVoters->ShowHeader = false;
     $pnlVoters->SortDirection = 1;
     $pnlVoters->AddColumn($colCnt);
     $pnlVoters->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroSuggestionVoteAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroSuggestionVoteAsUser->Suggestion->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID), $objProject ? QQ::Equal(QQN::NarroUser()->NarroSuggestionVoteAsUser->Suggestion->Text->NarroContextAsText->ProjectId, $objProject->ProjectId) : QQ::All());
     $pnlVoters->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroSuggestionVoteAsUser->SuggestionId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
     $pnlComments = new NarroUserDataGrid($this->tabTop);
     $pnlComments->CssClass = 'datagrid';
     $colUsername = $pnlComments->MetaAddColumn(QQN::NarroUser()->Username);
     $colUsername->HtmlEntities = false;
     $colUsername->Html = '<?=NarroLink::UserProfile($_ITEM->UserId, $_ITEM->Username)?>';
     $colCnt = new QDataGridColumn(t('Reviewers'));
     $colCnt->Html = '<?=$_ITEM->GetVirtualAttribute("suggestion_cnt")?>';
     $pnlComments->SortColumnIndex = 1;
     $pnlComments->ShowHeader = false;
     $pnlComments->SortDirection = 1;
     $pnlComments->AddColumn($colCnt);
     $pnlComments->AdditionalConditions = QQ::AndCondition(QQ::GreaterOrEqual(QQN::NarroUser()->NarroTextCommentAsUser->Created, $strDate), QQ::Equal(QQN::NarroUser()->NarroTextCommentAsUser->LanguageId, QApplication::GetLanguageId()), QQ::NotEqual(QQN::NarroUser()->UserId, NarroUser::ANONYMOUS_USER_ID));
     $pnlComments->AdditionalClauses = array(QQ::Count(QQN::NarroUser()->NarroTextCommentAsUser->TextCommentId, 'suggestion_cnt'), QQ::GroupBy(QQN::NarroUser()->UserId));
     $this->tabTop->Headers = array(t('Translators'), t('Reviewers'), t('Voters'), t('Comments'));
 }
开发者ID:Jobava,项目名称:narro,代码行数:67,代码来源:NarroTopPanel.class.php


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