$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')))); foreach ($objPersonArray as $objPerson) { _p($objPerson->FirstName . ' ' . $objPerson->LastName) . ' : ' . $objPerson->GetVirtualAttribute('diff'); _p('<br/>', false); } ?> <p><?php QApplication::$Database[1]->OutputProfiling(); ?> </p> <h2>The same as above and filter out most of the other fields by using a Select clause</h2> <p>This also demonstrates how to use the QQ::MathOp and QQ::Neg functions. </p> <?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))));
public function testNeg() { $objTest = new TypeTest(); $objTest->TestFloat = -1.0; $objTest->Save(); $objTest2 = new TypeTest(); $objTest2->TestFloat = -2.0; $objTest2->Save(); $objResArray = TypeTest::QueryArray(QQ::GreaterThan(QQ::Neg(QQN::TypeTest()->TestFloat), 1.0)); $this->assertEquals(1, count($objResArray)); if (count($objResArray) > 0) { $objRes = $objResArray[0]; $this->assertNotNull($objRes); if ($objRes) { $this->assertEquals(-2.0, $objRes->TestFloat); } } $objTest->Delete(); $objTest2->Delete(); }