GreaterThan() public static method

public static GreaterThan ( QQNode $objQueryNode, $mixValue )
$objQueryNode QQNode
 public function GetControlHtml()
 {
     $strLogContents = '';
     foreach (NarroLog::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroLog()->ProjectId, $this->intProjectId), QQ::Equal(QQN::NarroLog()->LanguageId, $this->intLanguageId), QQ::GreaterThan(QQN::NarroLog()->Date, $this->dttStart))) as $objLogEntry) {
         switch ($objLogEntry->Priority) {
             case NarroLog::PRIORITY_INFO:
                 $strLogContents .= '<div class="info"';
                 break;
             case NarroLog::PRIORITY_WARN:
                 $strLogContents .= '<div class="warning"';
                 break;
             case NarroLog::PRIORITY_ERROR:
                 $strLogContents .= '<div class="error"';
                 break;
             default:
                 $strLogContents .= '<div';
         }
         $strLogContents .= sprintf('title="%s">%s</div>', $objLogEntry->Date, nl2br(NarroString::HtmlEntities($objLogEntry->Message)));
     }
     $this->strText = sprintf('<div class="ui-accordion ui-widget ui-helper-reset ui-accordion-icons">
             <h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top">
             <span class="ui-icon ui-icon-triangle-1-s"></span>
             <a>%s</a>
             </h3>
             <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" style="max-height:300px;overflow:auto">
             %s
             </div>
             </div>', t('Operation log'), $strLogContents);
     return parent::GetControlHtml();
 }
Example #2
0
 public function testQueryCount()
 {
     $someDate = new QDateTime();
     $someDate->setDate(2006, 1, 1);
     $intItemCount = Milestone::QueryCount(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::Distinct());
     $this->assertEqual($intItemCount, 3);
     $intItemCount2 = Milestone::QueryCount(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::Clause(QQ::Distinct(), QQ::Distinct()));
     $this->assertEqual($intItemCount2, 3);
 }
Example #3
0
 public function testQueryArray()
 {
     $someDate = new QDateTime();
     $someDate->setDate(2006, 1, 1);
     $objItems = Milestone::QueryArray(QQ::GreaterThan(QQN::Milestone()->Project->StartDate, $someDate), QQ::OrderBy(QQN::Milestone()->Project->Name));
     $this->assertEqual(sizeof($objItems), 3);
     $this->assertEqual($objItems[0]->Name, "Milestone F");
     $this->assertEqual($objItems[0]->Project->Name, "Blueman Industrial Site Architecture");
     $this->assertEqual($objItems[1]->Name, "Milestone D");
     $this->assertEqual($objItems[1]->Project->Name, "State College HR System");
     $this->assertEqual($objItems[2]->Name, "Milestone E");
     $this->assertEqual($objItems[2]->Project->Name, "State College HR System");
 }
Example #4
0
 public static function _(QQNode $objQueryNode, $strSymbol, $mixValue, $mixValueTwo = null)
 {
     try {
         switch (strtolower(trim($strSymbol))) {
             case '=':
                 return QQ::Equal($objQueryNode, $mixValue);
             case '!=':
                 return QQ::NotEqual($objQueryNode, $mixValue);
             case '>':
                 return QQ::GreaterThan($objQueryNode, $mixValue);
             case '<':
                 return QQ::LessThan($objQueryNode, $mixValue);
             case '>=':
                 return QQ::GreaterOrEqual($objQueryNode, $mixValue);
             case '<=':
                 return QQ::LessOrEqual($objQueryNode, $mixValue);
             case 'in':
                 return QQ::In($objQueryNode, $mixValue);
             case 'not in':
                 return QQ::NotIn($objQueryNode, $mixValue);
             case 'like':
                 return QQ::Like($objQueryNode, $mixValue);
             case 'not like':
                 return QQ::NotLike($objQueryNode, $mixValue);
             case 'is null':
                 return QQ::IsNull($objQueryNode, $mixValue);
             case 'is not null':
                 return QQ::IsNotNull($objQueryNode, $mixValue);
             case 'between':
                 return QQ::Between($objQueryNode, $mixValue, $mixValueTwo);
             case 'not between':
                 return QQ::NotBetween($objQueryNode, $mixValue, $mixValueTwo);
             default:
                 throw new QCallerException('Unknown Query Comparison Operation: ' . $strSymbol, 0);
         }
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
Example #5
0
	<h2>Select all People where: the first name is alphabetically "greater than" the last name</h2>
	<ul>
<?php 
$objPersonArray = Person::QueryArray(QQ::GreaterThan(QQN::Person()->FirstName, QQN::Person()->LastName));
foreach ($objPersonArray as $objPerson) {
    _p('<li>' . $objPerson->FirstName . ' ' . $objPerson->LastName . '</li>', false);
}
?>
	</ul>
	<h2>Select all Projects where: the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website"</h2>
	<ul>
<?php 
$objProjectArray = Project::QueryArray(QQ::OrCondition(QQ::GreaterThan(QQN::Project()->ManagerPerson->FirstName, QQN::Project()->ManagerPerson->LastName), QQ::Like(QQN::Project()->Name, '%Website%')));
foreach ($objProjectArray as $objProject) {
    _p(sprintf('<li>%s (managed by %s %s)</li>', $objProject->Name, $objProject->ManagerPerson->FirstName, $objProject->ManagerPerson->LastName), false);
}
?>
	</ul>
	<h2>Select all Projects where: the Project ID <= 2 AND (the manager's first name is alphabetically "greater than" the last name, or who's name contains "Website")</h2>
	<ul>
<?php 
$objProjectArray = Project::QueryArray(QQ::AndCondition(QQ::OrCondition(QQ::GreaterThan(QQN::Project()->ManagerPerson->FirstName, QQN::Project()->ManagerPerson->LastName), QQ::Like(QQN::Project()->Name, '%Website%')), QQ::LessOrEqual(QQN::Project()->Id, 2)));
foreach ($objProjectArray as $objProject) {
    _p(sprintf('<li>%s (managed by %s %s)</li>', $objProject->Name, $objProject->ManagerPerson->FirstName, $objProject->ManagerPerson->LastName), false);
}
?>
	</ul>
</div>

<?php 
require '../includes/footer.inc.php';
 public function testSelect()
 {
     $objTest = new TypeTest();
     $objTest->TestFloat = 2.0;
     $objTest->Save();
     $objTest2 = new TypeTest();
     $objTest2->TestFloat = 3.0;
     $objTest2->Save();
     $objResArray = TypeTest::QueryArray(QQ::GreaterThan(QQ::Virtual('power2', QQ::Power(QQN::TypeTest()->TestFloat, 2.0)), 1.0), QQ::Clause(QQ::OrderBy(QQ::Virtual('power2')), QQ::Expand(QQ::Virtual('power2')), QQ::Select(QQ::Virtual('power2'))));
     $this->assertEquals(2, count($objResArray));
     if (2 == count($objResArray)) {
         $objRes = $objResArray[0];
         $this->assertNotNull($objRes);
         if ($objRes) {
             $this->assertNull($objRes->TestFloat);
             $this->assertEquals(4.0, $objRes->GetVirtualAttribute('power2'));
         }
         $objRes = $objResArray[1];
         $this->assertNotNull($objRes);
         if ($objRes) {
             $this->assertNull($objRes->TestFloat);
             $this->assertEquals(9.0, $objRes->GetVirtualAttribute('power2'));
         }
     }
     $objTest->Delete();
     $objTest2->Delete();
 }
Example #7
0
	<h3>Custom Load Query: Select all Projects with Budgets over $5000, ordered by Descending Budget</h3>
<?php 
// Custom Load Queries must have a resultset that returns all the fields of the
// table which corresponds to the ORM class you want to instantiate
// Note that because the InstantiateDb* methods in your ORM classes are code generated
// it is actually safe to use "SELECT *" for your Custom Load Queries.
$strQuery = 'SELECT project.* FROM project WHERE budget > 5000 ORDER BY budget DESC';
// perform the query
$objDbResult = $objDatabase->Query($strQuery);
// Use the Project::InstantiateDbResult on the $objDbResult to get an array of Project objects
$objProjectArray = Project::InstantiateDbResult($objDbResult);
// Iterate through the Project Array as you would any other ORM object
foreach ($objProjectArray as $objProject) {
    _p($objProject->Name . ' has a budget of $' . $objProject->Budget);
    _p('<br/>', false);
}
?>



	<h3>Qcodo Query: Select all Projects which have a Budget over $5000 and under $10000, ordered by Descending Budget</h3>
<?php 
// Perform the Query using Project::QueryArray, which will return an array of Project objects
// given a QQ Condition, and any optional QQ Clauses.
$objProjectArray = Project::QueryArray(QQ::AndCondition(QQ::GreaterThan(QQN::Project()->Budget, 5000), QQ::LessThan(QQN::Project()->Budget, 10000)), QQ::Clause(QQ::OrderBy(QQN::Project()->Budget, false)));
// Iterate through the Project Array like last time
foreach ($objProjectArray as $objProject) {
    _p($objProject->Name . ' has a budget of $' . $objProject->Budget);
    _p('<br/>', false);
}
require '../includes/footer.inc.php';
Example #8
0
 /**
  * Gets all associated ACTIVE GroupParticipations as an array of GroupParticipation objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return GroupParticipation[]
  */
 public function GetActiveGroupParticipationArray($objOptionalClauses = null)
 {
     if (is_null($this->intId)) {
         return array();
     }
     try {
         return GroupParticipation::QueryArray(QQ::AndCondition(QQ::Equal(QQN::GroupParticipation()->GroupId, $this->intId), QQ::OrCondition(QQ::IsNull(QQN::GroupParticipation()->DateEnd), QQ::GreaterThan(QQN::GroupParticipation()->DateEnd, QDateTime::Now()))), $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
<?php 
QApplication::$Database[1]->EnableProfiling();
$objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Virtual('diff', QQ::MathOp('+', QQN::Person()->ProjectAsManager->Spent, QQ::Neg(QQN::Person()->ProjectAsManager->Budget))), 20), QQ::Clause(QQ::OrderBy(QQ::Virtual('diff'), 'DESC'), QQ::Expand(QQ::Virtual('diff')), QQ::Select(array(QQ::Virtual('diff'), QQN::Person()->FirstName, QQN::Person()->LastName))));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName) . ' : ' . $objPerson->GetVirtualAttribute('diff');
    _p('<br/>', false);
}
?>
	<p><?php 
QApplication::$Database[1]->OutputProfiling();
?>
</p>

	<h2>SQL Function Example</h2>
	<p>Use the QQ::Abs and QQ::Sub functions to retrieve projects both over-budget and under-budget by $20.</p>
<?php 
QApplication::$Database[1]->EnableProfiling();
$objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Virtual('absdiff', QQ::Abs(QQ::Sub(QQN::Person()->ProjectAsManager->Spent, QQN::Person()->ProjectAsManager->Budget))), 20), QQ::Clause(QQ::OrderBy(QQ::Virtual('absdiff'), 'DESC'), QQ::Expand(QQ::Virtual('absdiff')), QQ::Select(array(QQ::Virtual('absdiff'), QQN::Person()->FirstName, QQN::Person()->LastName))));
foreach ($objPersonArray as $objPerson) {
    _p($objPerson->FirstName . ' ' . $objPerson->LastName) . ' : ' . $objPerson->GetVirtualAttribute('diff');
    _p('<br/>', false);
}
?>
	<p><?php 
QApplication::$Database[1]->OutputProfiling();
?>
</p>
</div>

<?php 
require '../includes/footer.inc.php';
 /**
  * Tests to ensure the example to work
  */
 public function testExample()
 {
     $objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Sub(QQN::Person()->ProjectAsManager->Spent, QQN::Person()->ProjectAsManager->Budget), 20));
     $this->assertGreaterThan(0, count($objPersonArray));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNotNull($objPerson->FirstName);
         $this->assertNotNull($objPerson->LastName);
     }
     $objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Virtual('diff', QQ::Sub(QQN::Person()->ProjectAsManager->Spent, QQN::Person()->ProjectAsManager->Budget)), 20), QQ::Clause(QQ::OrderBy(QQ::Virtual('diff'), 'DESC'), QQ::Expand(QQ::Virtual('diff'))));
     $this->assertGreaterThan(0, count($objPersonArray));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNotNull($objPerson->FirstName);
         $this->assertNotNull($objPerson->LastName);
         $this->assertNotNull($objPerson->GetVirtualAttribute('diff'));
     }
     $objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Virtual('diff', QQ::MathOp('-', QQN::Person()->ProjectAsManager->Spent, QQN::Person()->ProjectAsManager->Budget)), 20), QQ::Clause(QQ::OrderBy(QQ::Virtual('diff'), 'DESC'), QQ::Expand(QQ::Virtual('diff')), QQ::Select(array(QQ::Virtual('diff'), QQN::Person()->FirstName, QQN::Person()->LastName))));
     $this->assertGreaterThan(0, count($objPersonArray));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNotNull($objPerson->FirstName);
         $this->assertNotNull($objPerson->LastName);
         $this->assertNotNull($objPerson->GetVirtualAttribute('diff'));
     }
     $objPersonArray = Person::QueryArray(QQ::GreaterThan(QQ::Virtual('absdiff', QQ::Abs(QQ::Sub(QQN::Person()->ProjectAsManager->Spent, QQN::Person()->ProjectAsManager->Budget))), 20), QQ::Clause(QQ::OrderBy(QQ::Virtual('absdiff'), 'DESC'), QQ::Expand(QQ::Virtual('absdiff')), QQ::Select(array(QQ::Virtual('absdiff'), QQN::Person()->FirstName, QQN::Person()->LastName))));
     $this->assertGreaterThan(0, count($objPersonArray));
     foreach ($objPersonArray as $objPerson) {
         $this->assertNotNull($objPerson->FirstName);
         $this->assertNotNull($objPerson->LastName);
         $this->assertNotNull($objPerson->GetVirtualAttribute('absdiff'));
     }
 }
 public function dtgLocation_Bind()
 {
     $objClauses = array();
     if ($objClause = $this->dtgLocation->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     $objClause = QQ::Expand(QQN::Location()->CreatedByObject);
     array_push($objClauses, $objClause);
     $this->strLocation = $this->txtLocation->Text;
     if ($this->strLocation) {
         $this->dtgLocation->TotalItemCount = Location::QueryCount(QQ::AndCondition(QQ::Like(QQN::Location()->ShortDescription, '%' . $this->strLocation . '%'), QQ::GreaterThan(QQN::Location()->LocationId, 6)), $objClauses);
         if ($this->dtgLocation->TotalItemCount > 0) {
             $this->dtgLocation->ShowHeader = true;
             // Add the LimitClause information, as well
             if ($objClause = $this->dtgLocation->LimitClause) {
                 array_push($objClauses, $objClause);
             }
             $this->dtgLocation->DataSource = Location::QueryArray(QQ::AndCondition(QQ::Like(QQN::Location()->ShortDescription, '%' . $this->strLocation . '%'), QQ::GreaterThan(QQN::Location()->LocationId, 6)), $objClauses);
         } else {
             $this->dtgLocation->ShowHeader = false;
         }
     } else {
         $objExpansionMap[Location::ExpandCreatedByObject] = true;
         // Get Total Count b/c of Pagination
         $this->dtgLocation->TotalItemCount = Location::QueryCount(QQ::GreaterThan(QQN::Location()->LocationId, 6), $objClauses);
         if ($this->dtgLocation->TotalItemCount == 0) {
             $this->dtgLocation->ShowHeader = false;
         } else {
             if ($objClause = $this->dtgLocation->LimitClause) {
                 array_push($objClauses, $objClause);
             }
             $this->dtgLocation->DataSource = Location::QueryArray(QQ::GreaterThan(QQN::Location()->LocationId, 6), $objClauses);
             $this->dtgLocation->ShowHeader = true;
         }
     }
     $this->blnSearch = false;
 }
Example #12
0
 public static function LoadByPasswordResetCode($strPasswordResetCode)
 {
     // Reset code must be 32 characters
     if (strlen($strPasswordResetCode) != 32) {
         return null;
     }
     // Load all users with unexpired reset codes
     $arrUserAccount = UserAccount::QueryArray(QQ::AndCondition(QQ::Equal(QQN::UserAccount()->ActiveFlag, 1), QQ::IsNotNull(QQN::UserAccount()->PasswordResetCode), QQ::GreaterThan(QQN::UserAccount()->PasswordResetExpiry, QDateTime::Now())));
     // Check submitted reset code against any valid codes
     foreach ($arrUserAccount as $objUserAccount) {
         if (QApplication::CheckPassword($strPasswordResetCode, $objUserAccount->PasswordResetCode)) {
             // Match found
             return $objUserAccount;
         }
     }
     return null;
 }