當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Gender::find方法代碼示例

本文整理匯總了PHP中Gender::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gender::find方法的具體用法?PHP Gender::find怎麽用?PHP Gender::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gender的用法示例。


在下文中一共展示了Gender::find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getChartData

 public function getChartData()
 {
     $testId = Input::get('test');
     $startDate = date('Y-m-d', strtotime(Input::get('startDate')));
     $endDate = date('Y-m-d', strtotime(Input::get('endDate') . ' + 1 days'));
     $sportId = Input::get("sport");
     $genderId = Input::get("gender");
     $filteredTests = $this->getFilteredTests($testId, $startDate, $endDate, $sportId, $genderId);
     $test = $filteredTests['test'];
     $answeredTests = $filteredTests['answeredTests'];
     $ranges = $test->scales[0]->ranges;
     $scales = $test->scales;
     $responseData = array('cols' => array(), 'rows' => array());
     // Inserción de columnas
     $responseData['cols'][] = $this->createColumn('Escalas', 'string');
     $ranges = $test->scales[0]->ranges;
     foreach ($ranges as $range) {
         $label = 'Deportistas en: ' . $range->description . ' (' . $range->min . ', ' . $range->max . ')';
         $responseData['cols'][] = $this->createColumn($label, 'number');
     }
     // Preparación de datos de renglones
     $scalesResults = array();
     foreach ($scales as $scale) {
         $rangesValues = array();
         for ($i = 0; $i < $ranges->count(); $i++) {
             $rangesValues[] = 0;
         }
         $scalesResults[$scale->description] = $rangesValues;
     }
     // Cálculo de valores
     foreach ($answeredTests as $answeredTest) {
         $resultsByScale = $this->getResultsByScale($scales, $answeredTest->userAnswers);
         foreach ($resultsByScale as $resultByScale) {
             $scale = $resultByScale['scale'];
             $result = $resultByScale['result'];
             $rangeIndex = $this->getRangeIndex($ranges, $result);
             $scalesResults[$scale->description][$rangeIndex]++;
         }
     }
     // Inserción de renglones
     foreach ($scalesResults as $scaleName => $results) {
         $row = array();
         $row[] = $scaleName;
         foreach ($results as $result) {
             $row[] = $result;
         }
         $responseData['rows'][] = $this->createRow($row);
     }
     // Preparar encabezado y subtítulos
     $title = $test->name;
     $date = 'De ' . Input::get('startDate') . ' a ' . Input::get('endDate');
     $sport;
     $gender;
     if ($sportId != -1) {
         $sport = ' Deporte: ' . Sport::find($sportId)->description;
     } else {
         $sport = ' Deporte: Sin Especificar';
     }
     if ($genderId != -1) {
         $gender = ' Género: ' . Gender::find($genderId)->description;
     } else {
         $gender = ' Género: Sin Especificar';
     }
     return array('title' => $title, 'date' => $date, 'sport' => $sport, 'gender' => $gender, 'table' => $responseData);
 }
開發者ID:ebuzz,項目名稱:SAPE_CAR,代碼行數:65,代碼來源:ResultsController.php


注:本文中的Gender::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。