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


PHP QQ::ExpandAsArray方法代码示例

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


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

示例1: tblProjects_Bind

 /**
  * Bind the Projects table to the html table.
  *
  * @throws QCallerException
  */
 protected function tblProjects_Bind()
 {
     // Expand the PersonAsTeamMember node as an array so that it will be included in each item sent to the columns.
     $clauses = QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember);
     // We load the data source, and set it to the datagrid's DataSource parameter
     $this->tblProjects->DataSource = Project::LoadAll($clauses);
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:12,代码来源:column_values.php

示例2: testMultiLevel

 public function testMultiLevel()
 {
     $arrPeople = Person::LoadAll(QQ::Clause(QQ::ExpandAsArray(QQN::Person()->Address), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager->Milestone)));
     $targetPerson = null;
     foreach ($arrPeople as $objPerson) {
         if ($objPerson->LastName == "Wolfe") {
             $targetPerson = $objPerson;
         }
     }
     $this->assertEqual(sizeof($arrPeople), 12);
     $this->assertNotEqual($targetPerson, null, "Karen Wolfe found");
     $targetProject = null;
     foreach ($targetPerson->_ProjectAsManagerArray as $objProject) {
         if ($objProject->Name == "ACME Payment System") {
             $targetProject = $objProject;
         }
     }
     $this->assertEqual(sizeof($targetPerson->_ProjectAsManagerArray), 2, "2 projects found");
     $this->assertNotEqual($targetProject, null, "ACME Payment System project found");
     $targetMilestone = null;
     foreach ($targetProject->_MilestoneArray as $objMilestone) {
         if ($objMilestone->Name == "Milestone H") {
             $targetMilestone = $objMilestone;
         }
     }
     $this->assertEqual(sizeof($targetProject->_MilestoneArray), 4, "4 milestones found");
     $this->assertNotEqual($targetMilestone, null, "Milestone H found");
 }
开发者ID:eliud254,项目名称:q-auction,代码行数:28,代码来源:ExpandAsArrayTests.php

示例3: testSelectSubsetInExpandAsArray

 public function testSelectSubsetInExpandAsArray()
 {
     $objPersonArray = Person::LoadAll(QQ::Clause(QQ::Select(QQN::Person()->FirstName), QQ::ExpandAsArray(QQN::Person()->Address, QQ::Select(QQN::Person()->Address->Street, QQN::Person()->Address->City)), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager, QQ::Select(QQN::Person()->ProjectAsManager->StartDate)), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager->Milestone, QQ::Select(QQN::Person()->ProjectAsManager->Milestone->Name))));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNull($objPerson->LastName, "LastName should be null, since it was not selected");
         $this->assertNotNull($objPerson->Id, "Id should not be null since it's always added to the select list");
         if (sizeof($objPerson->_AddressArray) > 0) {
             foreach ($objPerson->_AddressArray as $objAddress) {
                 $this->assertNotNull($objAddress->Id, "Address->Id should not be null since it's always added to the select list");
                 $this->assertNull($objAddress->PersonId, "Address->PersonId should be null, since it was not selected");
             }
         }
         if (sizeof($objPerson->_ProjectAsManagerArray) > 0) {
             foreach ($objPerson->_ProjectAsManagerArray as $objProject) {
                 $this->assertNotNull($objProject->Id, "Project->Id should not be null since it's always added to the select list");
                 $this->assertNull($objProject->Name, "Project->Name should be null, since it was not selected");
                 if (sizeof($objProject->_MilestoneArray) > 0) {
                     foreach ($objProject->_MilestoneArray as $objMilestone) {
                         $this->assertNotNull($objMilestone->Id, "Milestone->Id should not be null since it's always added to the select list");
                         $this->assertNull($objMilestone->ProjectId, "Milestone->ProjectId should be null, since it was not selected");
                     }
                 }
             }
         }
     }
 }
开发者ID:hiptc,项目名称:dle2wordpress,代码行数:26,代码来源:ExpandAsArrayTests.php

示例4: lstProjects_Bind

 /**
  * Add the items to the project list.
  */
 public function lstProjects_Bind()
 {
     $clauses[] = QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember);
     $objProjects = Project::QueryArray(QQ::All(), $clauses);
     foreach ($objProjects as $objProject) {
         $item = new QHListItem($objProject->Name);
         $item->Tag = 'ol';
         $item->GetSubTagStyler()->OrderedListType = QOrderedListType::LowercaseRoman;
         foreach ($objProject->_PersonAsTeamMemberArray as $objPerson) {
             /****
              * Here we add a sub-item to each item before adding the item to the main list.
              */
             $item->AddItem($objPerson->FirstName . ' ' . $objPerson->LastName);
         }
         $this->lstProjects->AddItem($item);
     }
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:20,代码来源:hlist.php

示例5: dtrText_Conditions

 protected function dtrText_Conditions($blnReset = false)
 {
     $this->arrConditions = array(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->LanguageId, QApplication::GetLanguageId()), QQ::Equal(QQN::NarroContextInfo()->Context->Active, true), QQ::Equal(QQN::NarroContextInfo()->Context->File->Active, true)));
     if ($blnReset) {
         $this->intMaxRowCount = 0;
     }
     $this->arrClauses = array(QQ::Expand(QQN::NarroContextInfo()->Context), QQ::Expand(QQN::NarroContextInfo()->Context->Text), QQ::Expand(QQN::NarroContextInfo()->Context->File), QQ::Expand(QQN::NarroContextInfo()->Context->Project), QQ::Expand(QQN::NarroContextInfo()->ValidSuggestion));
     if ($this->lstProject->SelectedValue > 0) {
         $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->ProjectId, $this->lstProject->SelectedValue);
     }
     switch ($this->lstFilter->SelectedValue) {
         case self::SHOW_NOT_TRANSLATED:
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, false);
             break;
         case self::SHOW_NOT_APPROVED:
             $this->arrConditions[] = QQ::AndCondition(QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true));
             break;
         case self::SHOW_APPROVED:
             $this->arrConditions[] = QQ::IsNotNull(QQN::NarroContextInfo()->ValidSuggestionId);
             break;
         case self::SHOW_APPROVED_AND_NOT_APPROVED:
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, true);
             break;
         case self::SHOW_NOT_APPROVED_AND_NOT_TRANSLATED:
             $this->arrConditions[] = QQ::IsNull(QQN::NarroContextInfo()->ValidSuggestionId);
             break;
         case self::SHOW_NOT_APPROVED_AND_WITHOUT_VOTES:
             $this->arrConditions[] = QQ::Equal(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0);
             break;
         case self::SHOW_NOT_APPROVED_AND_WITH_VOTES:
             $this->arrConditions[] = QQ::NotEqual(QQ::SubSql('SELECT COUNT(*) FROM narro_suggestion_vote, narro_suggestion WHERE narro_suggestion_vote.suggestion_id=narro_suggestion.suggestion_id AND narro_suggestion.text_id={1}', QQN::NarroContextInfo()->Context->TextId), 0);
             break;
         case self::SHOW_IDENTICAL_APPROVED:
             $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
             $this->arrClauses[] = QQ::Distinct();
             $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionId), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId));
             break;
         case self::SHOW_IDENTICAL:
             $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
             $this->arrClauses[] = QQ::Distinct();
             $this->arrConditions[] = QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->Text->TextValueMd5, QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValueMd5), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QQN::NarroContextInfo()->LanguageId));
             break;
         case self::SHOW_ALL:
         default:
     }
     if ($this->txtFile->Text != t('all files') && $this->txtFile->Text != '') {
         if (preg_match("/^'.+'\$/", $this->txtFile->Text)) {
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1));
         } elseif (preg_match('/^".+"$/', $this->txtFile->Text)) {
             $this->arrConditions[] = QQ::Equal(QQN::NarroContextInfo()->Context->File->FilePath, substr($this->txtFile->Text, 1, -1));
         } else {
             $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->File->FilePath, '%' . $this->txtFile->Text . '%');
         }
     }
     if ($this->txtSearch->Text) {
         if (preg_match("/^'.+'\$/", $this->txtSearch->Text)) {
             $strLikeSearch = substr($this->txtSearch->Text, 1, -1);
         } elseif (preg_match('/^".+"$/', $this->txtSearch->Text)) {
             $strLikeSearch = substr($this->txtSearch->Text, 1, -1);
         } else {
             $strLikeSearch = '%' . $this->txtSearch->Text . '%';
         }
         switch ($this->lstSearchIn->SelectedValue) {
             case self::SEARCH_IN_TEXTS:
                 $this->arrConditions[] = QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch);
                 break;
             case self::SEARCH_IN_TRANSLATIONS:
                 $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
                 $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId()));
                 break;
             case self::SEARCH_IN_AUTHORS:
                 $this->arrClauses[] = QQ::ExpandAsArray(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText);
                 $this->arrConditions[] = QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId()));
                 break;
             case self::SEARCH_IN_CONTEXTS:
                 $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch));
                 break;
             case self::SEARCH_IN_ALL:
             default:
                 $this->arrClauses[] = QQ::Distinct();
                 $this->arrConditions[] = QQ::OrCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->TextValue, $strLikeSearch), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->SuggestionValue, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::AndCondition(QQ::Like(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->User->RealName, $strLikeSearch), QQ::Equal(QQN::NarroContextInfo()->Context->Text->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId())), QQ::Like(QQN::NarroContextInfo()->Context->Context, $strLikeSearch), QQ::Like(QQN::NarroContextInfo()->Context->Comment, $strLikeSearch));
         }
     }
     switch ($this->lstSort->SelectedValue) {
         case self::SORT_TEXT:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextValue, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TEXT_LENGTH:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Context->Text->TextWordCount, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TRANSLATION:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->ValidSuggestion->SuggestionValue, $this->lstSortDir->SelectedValue);
             break;
         case self::SORT_TRANSLATION_DATE:
             $this->arrClauses[] = QQ::OrderBy(QQN::NarroContextInfo()->Modified, $this->lstSortDir->SelectedValue);
             break;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:98,代码来源:NarroTranslatePanel.class.php

示例6: testExpand

 public function testExpand()
 {
     // Test intermediate nodes on expansion
     $clauses = QQ::Clause(QQ::Expand(QQN::Milestone()->Project->ManagerPerson));
     $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses);
     $this->assertTrue(!is_null($objMilestone->Name), "Milestone 1 has a name");
     $this->assertEqual($objMilestone->Name, "Milestone A", "Milestone 1 has name of Milestone A");
     $this->assertTrue(!is_null($objMilestone->Project->Name), "Project 1 has a name");
     $this->assertEqual($objMilestone->Project->Name, "ACME Website Redesign", "Project 1 has name of ACME Website Redesign");
     $this->assertTrue(!is_null($objMilestone->Project->ManagerPerson->FirstName), "Person 7 has a name");
     $this->assertEqual($objMilestone->Project->ManagerPerson->FirstName, "Karen", "Person 7 has first name of Karen");
     $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember), QQ::OrderBy(QQN::Project()->PersonAsTeamMember->Person->LastName, QQN::Project()->PersonAsTeamMember->Person->FirstName));
     // short reach
     $objProject = Project::QuerySingle(QQ::Equal(QQN::Project()->Id, 1), $clauses);
     $objPersonArray = $objProject->_PersonAsTeamMemberArray;
     $arrNamesOnly = array();
     foreach ($objPersonArray as $item) {
         $arrNamesOnly[] = $item->FirstName . " " . $item->LastName;
     }
     $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Project Team Member expansion is correct");
     // long reach
     $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Milestone()->Project->PersonAsTeamMember), QQ::OrderBy(QQN::Milestone()->Project->PersonAsTeamMember->Person->LastName, QQN::Milestone()->Project->PersonAsTeamMember->Person->FirstName));
     $objMilestone = Milestone::QuerySingle(QQ::Equal(QQN::Milestone()->Id, 1), $clauses);
     $objPersonArray = $objMilestone->Project->_PersonAsTeamMemberArray;
     $arrNamesOnly = array();
     foreach ($objPersonArray as $item) {
         $arrNamesOnly[] = $item->FirstName . " " . $item->LastName;
     }
     $this->assertEqual($arrNamesOnly, array("Samantha Jones", "Kendall Public", "Alex Smith", "Wendy Smith", "Karen Wolfe"), "Long reach Milestone to Project Team Member expansion is correct");
 }
开发者ID:tomVertuoz,项目名称:framework,代码行数:30,代码来源:BasicOrmTests.php

示例7: Wolfe

	<h3>Get All People Who Are on a Project Managed by Karen Wolfe (Person ID #7)<br/>showing the Project which is involved in the JOIN via Expand()</h3>
	<i>Notice how some people may be listed twice, once for each project which he or she is part of that is managed by Karen Wolfe.</i><br/><br/>
<?php 
$objPersonArray = Person::QueryArray(QQ::Equal(QQN::Person()->ProjectAsTeamMember->Project->ManagerPersonId, 7), QQ::Clause(QQ::Expand(QQN::Person()->ProjectAsTeamMember->Project), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    printf('%s %s (via the "%s" project)<br/>', QApplication::HtmlEntities($objPerson->FirstName), QApplication::HtmlEntities($objPerson->LastName), QApplication::HtmlEntities($objPerson->_ProjectAsTeamMember->Name));
}
?>



	<br/>
	<h3>Same as above, but this time, use ExpandAsArray()</h3>
	<i>Notice how each person is only listed once... but each person has an internal/virtual <b>_ProjectAsTeamMemberArray</b> which may list more than one project.</i><br/><br/>
<?php 
$objPersonArray = Person::QueryArray(QQ::Equal(QQN::Person()->ProjectAsTeamMember->Project->ManagerPersonId, 7), QQ::Clause(QQ::ExpandAsArray(QQN::Person()->ProjectAsTeamMember), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName, QQN::Person()->ProjectAsTeamMember->Project->Name)));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName);
    _p('<br/>', false);
    // Now, instead of using the _ProjectAsTeamMember virtual attribute, we will use
    // the _ProjectAsTeamMemberArray virtual attribute, which gives us an array of Project objects
    $strProjectNameArray = array();
    foreach ($objPerson->_ProjectAsTeamMemberArray as $objProject) {
        array_push($strProjectNameArray, QApplication::HtmlEntities($objProject->Name));
    }
    printf('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;via: %s<br/>', implode(', ', $strProjectNameArray));
}
?>

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

示例8: foreach

		number of rows returned from SQL in that one query is equal to:<br />
		<center><b>(Num of Persons) * (Num of Projects) * (Num of Milestones) *
		(Num of Addresses)</b></center><br />
		You can see how it can get out of hand quickly - and the performance gains
		you get out of issuing a single query can become a detriment instead, because
		of the amount of data that gets transfered from your database server to PHP.
		Thus, this approach only makes sense if you don't expect to have hundreds of
		items in each of the tables you're extracting the data from. Be sure to look
		at the SQL statement generated by QQuery, and try running it yourself, keeping
		the number of results in mind. 
	</div>
	<h3>Projects and Addresses for each Person</h3>    

<?php 
QApplication::$Database[1]->EnableProfiling();
$people = Person::LoadAll(QQ::Clause(QQ::ExpandAsArray(QQN::Person()->Address), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager->Milestone)));
foreach ($people as $person) {
    echo "<b>" . $person->FirstName . " " . $person->LastName . "</b><br />";
    echo "Addresses: ";
    if (sizeof($person->_AddressArray) == 0) {
        echo "none";
    } else {
        foreach ($person->_AddressArray as $address) {
            echo $address->Street . "; ";
        }
    }
    echo "<br />";
    echo "Projects where this person is a project manager: ";
    if (sizeof($person->_ProjectAsManagerArray) == 0) {
        echo "none<br />";
    } else {
开发者ID:eliud254,项目名称:q-auction,代码行数:31,代码来源:expandasarray.php

示例9: Manage

<div id="demoZone">
	<h2>Get All People, Specifying the Project They Manage (if any), for Projects that have 'ACME' or 'HR' in it</h2>
	<p><em>Notice how some people may be listed twice, if they manage more than one project.</em></p>
	<ul>
<?php 
$objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Expand(QQN::Person()->ProjectAsManager), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    printf('<li>%s %s (managing the "%s" project)</li>', QApplication::HtmlEntities($objPerson->FirstName), QApplication::HtmlEntities($objPerson->LastName), QApplication::HtmlEntities($objPerson->_ProjectAsManager->Name), false);
}
?>
	</ul>
	<h3>Same as above, but this time, use ExpandAsArray()</h3>
	<em>Notice how each person is only listed once... but each person has an internal/virtual <strong>_ProjectAsManagerArray</strong> which may list more than one project.</em></p>
<?php 
$objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::ExpandAsArray(QQN::Person()->ProjectAsManager), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    _p('<li>' . $objPerson->FirstName . ' ' . $objPerson->LastName, false);
    // Now, instead of using the _ProjectAsManager virtual attribute, we will use
    // the _ProjectAsManagerArray virtual attribute, which gives us an array of Project objects
    $strProjectNameArray = array();
    foreach ($objPerson->_ProjectAsManagerArray as $objProject) {
        array_push($strProjectNameArray, QApplication::HtmlEntities($objProject->Name));
    }
    printf(' via: %s</li>', implode(', ', $strProjectNameArray));
}
?>
</div>

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

示例10: testExpandReverseReferences

 /**
  * Make sure that expansions looking backwards are pointing to the same object looking forwards
  */
 public function testExpandReverseReferences()
 {
     // Test virtual binding of reverse relationships
     $clauses = [QQ::Expand(QQN::Person()->ProjectAsManager)];
     $objPerson = Person::QuerySingle(QQ::All(), $clauses);
     $objPerson->FirstName = 'test';
     $objProject = $objPerson->ProjectAsManager;
     $objPerson2 = $objProject->ManagerPerson;
     $this->assertEquals('test', $objPerson2->FirstName);
     // Test forward reference looking back
     $clauses = [QQ::Expand(QQN::Project()->ManagerPerson)];
     $objProject = Project::QuerySingle(QQ::All(), $clauses);
     $objProject->Name = 'test';
     $objPerson = $objProject->ManagerPerson;
     $objProject2 = $objPerson->ProjectAsManager;
     $this->assertEquals('test', $objProject2->Name);
     // test unique reverse reference
     $clauses = [QQ::Expand(QQN::Person()->Login)];
     $objPerson = Person::QuerySingle(QQ::All(), $clauses);
     $objPerson->FirstName = 'test';
     $objLogin = $objPerson->Login;
     $objPerson2 = $objLogin->Person;
     $this->assertEquals('test', $objPerson2->FirstName);
     // test many-to-many expansion
     $clauses = [QQ::ExpandAsArray(QQN::Project()->PersonAsTeamMember)];
     $objProject = Project::QuerySingle(QQ::All(), $clauses);
     $objProject->Name = 'test';
     $objPersonArray = $objProject->_PersonAsTeamMemberArray;
     $objProject2 = $objPersonArray[0]->_ProjectAsTeamMember;
     $this->assertEquals('test', $objProject2->Name);
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:34,代码来源:BasicOrmTest.php

示例11: testConditionalExpansionAssociation

 public function testConditionalExpansionAssociation()
 {
     // Conditional expansion on association nodes really can only work with the PK of the join.
     // Get all projects, and also expand on related projects if the id is 1
     $a = Project::QueryArray(QQ::All(), [QQ::ExpandAsArray(QQN::Project()->ParentProjectAsRelated, QQ::Equal(QQN::Project()->ParentProjectAsRelated->ProjectId, 1)), QQ::ExpandAsArray(QQN::Project()->ProjectAsRelated, QQ::Equal(QQN::Project()->ProjectAsRelated->Project->Id, 1)), QQ::OrderBy(QQN::Project()->Id)]);
     $this->assertEquals(1, $a[2]->_ParentProjectAsRelatedArray[0]->Id);
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:7,代码来源:ExpandAsArrayTest.php

示例12: LoadByUserId

 public static function LoadByUserId($intUserId, $objOptionalClauses = null)
 {
     $objUser = NarroUser::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroUser()->UserId, $intUserId)), QQ::ExpandAsArray(QQN::NarroUser()->NarroUserRoleAsUser));
     if (!$objUser instanceof NarroUser) {
         return false;
     }
     foreach ($objUser->_NarroUserRoleAsUserArray as $objRole) {
         /* @var $objRole NarroUserRole */
         $arrRolePermission = NarroRolePermission::LoadArrayByRoleId($objRole->RoleId, QQ::Expand(QQN::NarroRolePermission()->Permission));
         foreach ($arrRolePermission as $objRolePermission) {
             $objUser->arrPermissions[$objRolePermission->Permission->PermissionName . '-' . $objRole->LanguageId . '-' . $objRole->ProjectId] = $objRolePermission;
         }
     }
     if (isset($objUser->Preferences['Language'])) {
         $objLanguage = NarroLanguage::LoadByLanguageCode($objUser->Preferences['Language']);
         if ($objLanguage instanceof NarroLanguage) {
             $objUser->Language = $objLanguage;
         } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
             $objUser->Language = QApplication::$TargetLanguage;
         }
     } elseif (QApplication::$TargetLanguage instanceof NarroLanguage) {
         $objUser->Language = QApplication::$TargetLanguage;
     }
     return $objUser;
 }
开发者ID:Jobava,项目名称:narro,代码行数:25,代码来源:NarroUser.class.php

示例13: testConditionalExpansion

 public function testConditionalExpansion()
 {
     $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Person()->Address), QQ::Expand(QQN::Person()->ProjectAsManager, QQ::Equal(QQN::Person()->ProjectAsManager->ProjectStatusTypeId, ProjectStatusType::Open)), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager->Milestone), QQ::OrderBy(QQN::Person()->Id));
     $targetPersonArray = Person::LoadAll($clauses);
     $targetPerson = reset($targetPersonArray);
     $this->assertEqual($targetPerson->Id, 1, "Person 1 found.");
     $this->assertNotNull($targetPerson->_ProjectAsManager, "Person 1 has a project.");
     $targetPerson = end($targetPersonArray);
     $this->assertEqual($targetPerson->Id, 12, "Person 12 found.");
     $this->assertNull($targetPerson->_ProjectAsManager, "Person 12 does not have a project.");
     //TODO: Conditional Array Expansion, requires API change
 }
开发者ID:tomVertuoz,项目名称:framework,代码行数:12,代码来源:ExpandAsArrayTests.php

示例14: manage

	<h2>Get the last names of all the people, and the amount spent on the project they manage (if any), for Projects that
	have 'ACME' or 'HR' in it. Sort the result by Last Name, then First Name</h2>
	<p><i>Notice how some people may be listed twice, if they manage more than one project.</i></p>
	<ul>
<?php 
$objPersonArray = Person::QueryArray(QQ::OrCondition(QQ::Like(QQN::Person()->ProjectAsManager->Name, '%ACME%'), QQ::Like(QQN::Person()->ProjectAsManager->Name, '%HR%')), QQ::Clause(QQ::Select(QQN::Person()->LastName), QQ::Expand(QQN::Person()->ProjectAsManager, null, QQ::Select(QQN::Person()->ProjectAsManager->Spent)), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
foreach ($objPersonArray as $objPerson) {
    printf("<li>%s's project spent \$%0.2f</li>", QApplication::HtmlEntities($objPerson->LastName), QApplication::HtmlEntities($objPerson->_ProjectAsManager->Spent));
}
?>
	</ul>
	<h3>Projects and Addresses for each Person</h3>
	<ul>
<?php 
$people = Person::LoadAll(QQ::Clause(QQ::Select(QQN::Person()->FirstName), QQ::ExpandAsArray(QQN::Person()->Address, QQ::Select(QQN::Person()->Address->Street, QQN::Person()->Address->City)), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager, QQ::Select(QQN::Person()->ProjectAsManager->StartDate)), QQ::ExpandAsArray(QQN::Person()->ProjectAsManager->Milestone, QQ::Select(QQN::Person()->ProjectAsManager->Milestone->Name))));
foreach ($people as $person) {
    echo "<li><b>" . $person->FirstName . "</b><br />";
    assert(is_null($person->LastName));
    echo "Addresses: ";
    if (sizeof($person->_AddressArray) == 0) {
        echo "none";
    } else {
        foreach ($person->_AddressArray as $address) {
            echo $address->Street . ', ' . $address->City . "; ";
            assert(is_null($address->PersonId));
        }
    }
    echo "<br />";
    echo "Projects where this person is a project manager: ";
    if (sizeof($person->_ProjectAsManagerArray) == 0) {
开发者ID:hiptc,项目名称:dle2wordpress,代码行数:30,代码来源:qqselect.php

示例15: GetTmx

 /**
  * Returns a tmx file
  * @param QQCondition $objLangCondition e.g. QQ::In(QQN::NarroText()->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId());
  * @return a tmx file, formatted as a string
  */
 public static function GetTmx($objLangCondition)
 {
     $tmx = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE tmx SYSTEM "tmx13.dtd"><tmx />');
     $tmx->addAttribute('version', '1.3');
     $header = $tmx->addChild('header');
     // mandatory
     $header->addAttribute('creationtool', "Narro");
     $header->addAttribute('creationtoolversion', NARRO_VERSION);
     $header->addAttribute('segtype', "sentence");
     $header->addAttribute('o-tmf', "ABCTransMem");
     $header->addAttribute('adminlang', NarroLanguage::SOURCE_LANGUAGE_CODE);
     $header->addAttribute('srclang', NarroLanguage::SOURCE_LANGUAGE_CODE);
     $header->addAttribute('datatype', "PlainText");
     // optional
     $header->addAttribute('creationdate', QDateTime::NowToString('YYYYMMDDThhmmssZ'));
     if (QApplication::$User) {
         $header->addAttribute('creationid', QApplication::$User->Username);
     }
     $header->addAttribute('changedate', "19970314T023401Z");
     $header->addAttribute('o-encoding', "utf-8");
     $body = $tmx->addChild('body');
     $strQuery = NarroText::GetQueryStatement($objQueryBuilder, QQ::AndCondition(QQ::IsNotNull(QQN::NarroText()->NarroSuggestionAsText->SuggestionId), $objLangCondition), array(QQ::ExpandAsArray(QQN::NarroText()->NarroSuggestionAsText)), array(), false);
     $objDbResult = NarroText::GetDatabase()->Query($strQuery);
     $intRowCount = $objDbResult->CountRows();
     $intLastTextId = 0;
     while ($objDbRow = $objDbResult->GetNextRow()) {
         $objText = NarroText::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, null, $objQueryBuilder->ColumnAliasArray);
         if ($intLastTextId != $objText->TextId) {
             $intLastTextId = $objText->TextId;
             $tu = $body->addChild('tu');
             $tu->addAttribute('tuid', $objText->TextId);
             $tu->addAttribute('datatype', 'Text');
             // $tu->addAttribute('usagecount', $objText->CountNarroContextsAsText());
             // $objLastContext = NarroContext::QuerySingle(QQ::Equal(QQN::NarroContext()->TextId, $objText->TextId), array(QQ::OrderBy(QQN::NarroContext()->Created, 0)));
             // if ($objLastContext && $objLastContext->Created instanceof QDateTime)
             // $tu->addAttribute('lastusagedate', $objLastContext->Created->qFormat('YYYYMMDDThhmmssZ'));
             $tuv = $tu->addChild('tuv');
             $tuv->addAttribute('xml:lang', NarroLanguage::SOURCE_LANGUAGE_CODE);
             $seg = $tuv->addChild('seg');
             $tuv->seg = $objText->TextValue;
             if ($objText->Created instanceof QDateTime) {
                 $tuv->addAttribute('creationdate', $objText->Created->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objText->Modified instanceof QDateTime) {
                 $tuv->addAttribute('changedate', $objText->Modified->qFormat('YYYYMMDDThhmmssZ'));
             }
         }
         foreach ($objText->_NarroSuggestionAsTextArray as $objSuggestion) {
             /* @var $objSuggestion NarroSuggestion */
             $tuv = $tu->addChild('tuv');
             $tuv->addAttribute('xml:lang', $objSuggestion->Language->LanguageCode);
             $seg = $tuv->addChild('seg');
             $tuv->seg = $objSuggestion->SuggestionValue;
             if ($objSuggestion->Created instanceof QDateTime) {
                 $tuv->addAttribute('creationdate', $objSuggestion->Created->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objSuggestion->Modified instanceof QDateTime) {
                 $tuv->addAttribute('changedate', $objSuggestion->Modified->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objSuggestion->User instanceof NarroUser) {
                 $tuv->addAttribute('creationid', $objSuggestion->User->RealName);
             }
             // $tuv->addAttribute('usagecount', $objSuggestion->CountNarroContextInfosAsValidSuggestion());
             // $objLastContextInfo = NarroContextInfo::QuerySingle(QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, $objSuggestion->SuggestionId), array(QQ::OrderBy(QQN::NarroContextInfo()->Created, 0)));
             // if ($objLastContextInfo && $objLastContextInfo->Created instanceof QDateTime)
             // $tuv->addAttribute('lastusagedate', $objLastContextInfo->Created->qFormat('YYYYMMDDThhmmssZ'));
         }
     }
     return $tmx->asXML();
 }
开发者ID:Jobava,项目名称:narro,代码行数:75,代码来源:NarroLanguage.class.php


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