/** * Main DataGen Runner * @return void */ public static function Run() { self::$SystemStartDate = new QDateTime('2004-01-01'); self::$MaximumPersonId = Person::QuerySingle(QQ::All(), QQ::OrderBy(QQN::Person()->Id, false))->Id; self::DisplayForEachTaskStart($strDescription = 'Generating Signup Forms for Ministry', Ministry::CountByActiveFlag(true)); foreach (Ministry::LoadArrayByActiveFlag(true) as $objMinistry) { self::DisplayForEachTaskNext($strDescription); $intCount = rand(self::FormsPerMinistryMinimum, self::FormsPerMinistryMaximum); self::DisplayForEachTaskStart($strDescriptionInside = ' Generating Signup Forms', $intCount); for ($i = 0; $i < $intCount; $i++) { self::DisplayForEachTaskNext($strDescriptionInside); self::GenerateFormInMinistry($objMinistry); } self::DisplayForEachTaskEnd($strDescriptionInside, true); } self::DisplayForEachTaskEnd($strDescription); }
public function testQuerySingleEmpty() { $targetPerson = Person::QuerySingle(QQ::Equal(QQN::Person()->Id, 1241243)); $this->assertEqual($targetPerson, null, "QuerySingle should return null for a not-found record"); }
/** * Load a single Person object, * by PrimaryEmailId Index(es) * @param integer $intPrimaryEmailId * @return Person */ public static function LoadByPrimaryEmailId($intPrimaryEmailId, $objOptionalClauses = null) { return Person::QuerySingle(QQ::Equal(QQN::Person()->PrimaryEmailId, $intPrimaryEmailId), $objOptionalClauses); }
public function testOrderByReverseReference() { // orders by the private key of the reverse reference node. $objPerson = Person::QuerySingle(QQ::IsNotNull(QQN::Person()->ProjectAsManager->Id), [QQ::OrderBy(QQN::Person()->ProjectAsManager)]); $this->assertEquals(7, $objPerson->Id, "Manager of first project found."); }
The next few examples will examine all three major constructs (<b>QQ Node</b>, <b>QQ Condition</b> and <b>QQ Clause</b>) in greater detail.<br/><br/> And as a final note, notice that <b>Qcodo Query</b> doesn't have any construct to describe what would normally be your SELECT clause. This is because we take advantage of the code generation process to allow <b>Qcodo Query</b> to automagically "know" which fields that should be SELECT-ed based on the query, conditions and clauses you are performing. This will allow a lot greater flexbility in your data model. Because the framework is now taking care of column names, etc., instead of the developer needing to manually hard code it, you can make changes to columns in your tables without needing to rewrite your <b>Qcodo Query</b> calls. </div> <h3>QuerySingle Example</h3> <?php $objPerson = Person::QuerySingle(QQ::Equal(QQN::Person()->Id, 1)); // Notice that QuerySingle returned just a single Person object _p($objPerson->FirstName . ' ' . $objPerson->LastName); _p('<br/>', false); ?> <h3>QueryArray Example</h3> <?php $objPersonArray = Person::QueryArray(QQ::In(QQN::Person()->Id, array(5, 6, 8))); // Notice that QueryArray returns an array of Person objects... this will // be true even if the result set only yields 1 row.= foreach ($objPersonArray as $objPerson) { _p($objPerson->FirstName . ' ' . $objPerson->LastName); _p('<br/>', false);
/** * Load a single Person object, * by Email Index(es) * @param string $strEmail * @return Person */ public static function LoadByEmail($strEmail) { return Person::QuerySingle(QQ::Equal(QQN::Person()->Email, $strEmail)); }
public function testNullArray() { $arrPeople = Person::QuerySingle(QQ::Equal(QQN::Person()->Id, 2)); $this->assertTrue(is_null($arrPeople->_ProjectAsManagerArray), "_ProjectAsManagerArray is null"); }
public function testTypeExpansion() { $clauses = QQ::Clause(QQ::ExpandAsArray(QQN::Person()->PersonType)); $objPerson = Person::QuerySingle(QQ::Equal(QQN::Person()->Id, 7), $clauses); $intPersonTypeArray = $objPerson->_PersonTypeArray; $this->assertEqual($intPersonTypeArray, array(PersonType::Manager, PersonType::CompanyCar), "PersonType expansion is correct"); }
/** * Load a single Person object, * by Username Index(es) * @param string $strUsername * @return Person */ public static function LoadByUsername($strUsername) { return Person::QuerySingle(QQ::Equal(QQN::Person()->Username, $strUsername)); }