public function parse() { $directors = DB_nad_directorQuery::create()->orderByLastName()->orderByFirstName()->find()->toArray(); $director_count = count($directors); if ($director_count % 2 !== 0) { $director_count++; } return array("first" => array_slice($directors, 0, $director_count / 2), "second" => array_slice($directors, $director_count / 2)); }
protected function getModelCriteria() { $input = self::getRequiredInput(array("sort_by" => FILTER_UNSAFE_RAW, "is_ascending" => FILTER_VALIDATE_BOOLEAN)) + self::getInput(array("search" => FILTER_UNSAFE_RAW)); $query = DB_nad_directorQuery::create(); if ($input["search"] != "") { $query->filterByName($input["search"])->_or()->filterByOrganization("%" . $input["search"] . "%"); } $query->orderBy($input["sort_by"], $input["is_ascending"] ? Criteria::ASC : Criteria::DESC); return $query; }