protected function Form_Create() { $count = 10000; Project::ClearCache(); Person::ClearCache(); // Create test persons in database. // Tiny objects if (Person::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objPerson = new Person(); $objPerson->FirstName = 'FirstName' . $i; $objPerson->LastName = 'LastName' . $i; $objPerson->Save(); } } // Bigger objects with expansion if (Project::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objProject = new Project(); $objProject->Name = 'Project' . $i; $objProject->ProjectStatusTypeId = ProjectStatusType::Open; $objProject->ManagerPersonId = $i % 1000 + 1000; $objProject->Description = 'Description' . $i; $objProject->StartDate = QDateTime::Now(); $objProject->EndDate = QDateTime::Now(); $objProject->Budget = $i; $objProject->Spent = 1; $objProject->Save(); } } $this->pnlTiny = new QPanel($this); $this->pnlTiny->Name = '10,000 Person Objects'; $this->pnlBig = new QPanel($this); $this->pnlBig->Name = '10,000 Project Objects With Expansion'; $this->btnGo = new QButton($this); $this->btnGo->Text = 'Go'; $this->btnGo->AddAction(new QClickEvent(), new QAjaxAction('Go_Click')); }
public function dtgProjects_Bind() { // Get Total Count b/c of Pagination $this->dtgProjects->TotalItemCount = Project::CountAll(); $objClauses = array(); if ($objClause = $this->dtgProjects->OrderByClause) { $objClauses[] = $objClause; } if ($objClause = $this->dtgProjects->LimitClause) { $objClauses[] = $objClause; } // Create a virtual attribute that lets us know if this Project is related to ACME $objClauses[] = QQ::Expand(QQ::Virtual('assn_item', QQ::SubSql('select project_id from related_project_assn where child_project_id = {1} and project_id = 1', QQN::Project()->Id))); $this->dtgProjects->DataSource = Project::LoadAll($objClauses); }