本文整理匯總了PHP中Index::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Index::findFirst方法的具體用法?PHP Index::findFirst怎麽用?PHP Index::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Index
的用法示例。
在下文中一共展示了Index::findFirst方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getEightAddFive
public function getEightAddFive($examinee_info)
{
$result = $this->modelsManager->createBuilder()->columns(array('IndexAns.index_id as id', 'IndexAns.score as score'))->from('IndexAns')->where('IndexAns.examinee_id = ' . $examinee_info->id)->orderBy('IndexAns.score desc')->getQuery()->execute()->toArray();
$index_count = count($result);
$rtn_array = array();
if ($index_count < 8) {
$rtn_array['strong'] = array_slice($result, 0, $index_count);
$rtn_array['weak'] = array();
} else {
if ($index_count < 13) {
$rtn_array['strong'] = array_slice($result, 0, 8);
$rtn_array['weak'] = array_reverse(array_slice($result, 8, $index_count - 8));
} else {
$rtn_array['strong'] = array_slice($result, 0, 8);
$rtn_array['weak'] = array_reverse(array_slice($result, $index_count - 6, 5));
}
}
$strong_exist_array = array();
foreach ($rtn_array['strong'] as &$strong_value) {
$index = Index::findFirst(array('id=?1', 'bind' => array(1 => $strong_value['id'])));
$strong_value['chs_name'] = $index->chs_name;
$middle = array();
$middle = MiddleLayer::find(array('father_chs_name=?1', 'bind' => array(1 => $strong_value['chs_name'])))->toArray();
$children = array();
$children = $this->getChildrenOfIndexDesc($index->name, $index->children, $examinee_info->id);
foreach ($children as &$children_info) {
if (!isset($children_info['raw_score'])) {
$children_info['raw_score'] = null;
}
}
$strong_value['count'] = count($children);
$tmp = array();
$children = $this->foo($children, $tmp);
// echo '<pre>';
// print_r($children);
// exit();
$strong_value['children'] = array();
$number_count = 0;
foreach ($middle as $middle_info) {
$outter_tmp = array();
$middle_children = explode(',', $middle_info['children']);
$outter_tmp_score = 0;
foreach ($middle_children as $children_name) {
$inner_tmp = array();
$key = array_search($children_name, $children);
$number = (intval($key) + 4) / 4;
if ($number > 3) {
$number = null;
}
$inner_tmp['name'] = $children_name;
$inner_tmp['raw_score'] = $children[$key + 3];
$inner_tmp['ans_score'] = $children[$key + 1];
$outter_tmp_score += $inner_tmp['ans_score'];
$inner_tmp['number'] = $number;
$strong_value['children'][] = $inner_tmp;
}
$outter_tmp['name'] = null;
$outter_tmp['raw_score'] = null;
$outter_tmp['ans_score'] = $outter_tmp_score;
$outter_tmp['number'] = null;
$strong_value['children'][] = $outter_tmp;
}
}
//進行逆向重排列
$week_exist_array = array();
foreach ($rtn_array['weak'] as &$strong_value) {
$index = Index::findFirst(array('id=?1', 'bind' => array(1 => $strong_value['id'])));
$strong_value['chs_name'] = $index->chs_name;
$middle = array();
$middle = MiddleLayer::find(array('father_chs_name=?1', 'bind' => array(1 => $strong_value['chs_name'])))->toArray();
$children = array();
$children = $this->getChildrenOfIndexDesc($index->name, $index->children, $examinee_info->id);
$children = array_reverse($children);
foreach ($children as &$children_info) {
if (!isset($children_info['raw_score'])) {
$children_info['raw_score'] = null;
}
}
$strong_value['count'] = count($children);
$tmp = array();
$children = $this->foo($children, $tmp);
$strong_value['children'] = array();
$number_count = 0;
foreach ($middle as $middle_info) {
$outter_tmp = array();
$middle_children = explode(',', $middle_info['children']);
$outter_tmp_score = 0;
foreach ($middle_children as $children_name) {
$inner_tmp = array();
$key = array_search($children_name, $children);
$number = (intval($key) + 4) / 4;
if ($number > 3) {
$number = null;
}
$inner_tmp['name'] = $children_name;
$inner_tmp['raw_score'] = $children[$key + 3];
$inner_tmp['ans_score'] = $children[$key + 1];
$outter_tmp_score += $inner_tmp['ans_score'];
$inner_tmp['number'] = $number;
$strong_value['children'][] = $inner_tmp;
//.........這裏部分代碼省略.........
示例2: handleChildComment
public function handleChildComment()
{
$data_1 = $this->hanldleChildSheetByNumber(0);
$data_2 = $this->hanldleChildSheetByNumber(1);
$rtn_data = array();
foreach ($data_1 as $key => $value) {
$inner_array = array();
$index_info = Index::findFirst(array('chs_name =:chs_name:', 'bind' => array('chs_name' => $value['index_name'])));
if (!isset($index_info->id)) {
throw new Exception('Error not find in table index ' . print_r($value['index_name'], true));
}
$inner_array['index_id'] = $index_info->id;
$inner_array['index_chs_name'] = $value['index_name'];
$inner_array['child_chs_name'] = $value['child_name'];
$inner_array['advantage'] = $value['advantage'];
$inner_array['disadvantage'] = $data_2[$key]['disadvantage'];
if ($value['index_name'] != $data_2[$key]['index_name'] || $value['child_name'] != $data_2[$key]['child_name']) {
throw new Exception('Error not find ' . print_r($value['index_name']));
}
$rtn_data[] = $inner_array;
}
return $rtn_data;
#以下為測試代碼
// $not_child = array();
// $child = array();
// foreach($data_1 as $key=>$value){
// $inner_array = array();
// $index_info = Index::findFirst(array('chs_name =:chs_name:','bind'=>array('chs_name'=>$value['index_name'])));
// if (!isset($index_info->id)){
// throw new Exception( 'Error not find in table index '.print_r($value['index_name'], true));
// }
// //加一個判定指標判定
// if ($index_info->name == 'zb_ldnl'){
// //zb_ldnl 0,0,0,0,0
// $child_info = Index::findFirst(array('chs_name =:chs_name:','bind'=>array('chs_name'=>$value['child_name'])));
// if (!isset($child_info->id)){
// $not_child[] = $value['index_name'].'-'.$value['child_name'];
// }else {
// $child[$value['index_name']][] = $child_info->name;
// }
// }else if ($index_info->name == 'zb_gzzf'){
// //zb_gzzf 1,0,1,1,1,1,1
// //X4,zb_rjgxtjsp,chg,Y3,Q3,spmabc,aff
// if ($value['child_name'] == '人際關係調節水平'){
// $child_info = Index::findFirst(array('chs_name =:chs_name:','bind'=>array('chs_name'=>$value['child_name'])));
// if (!isset($child_info->id)){
// $not_child[] = $value['index_name'].'-'.$value['child_name'];
// }else {
// $child[$value['index_name']][] = $child_info->name;
// }
// }else{
// $child_info = Factor::findFirst(array('chs_name =:chs_name:','bind'=>array('chs_name'=>$value['child_name'])));
// if (!isset($child_info->id)){
// $not_child[] = $value['index_name'].'-'.$value['child_name'];
// }else {
// $child[$value['index_name']][] = $child_info->name;
// }
// }
// }else {
// //下屬全為因子的情況
// $child_info = Factor::findFirst(array('chs_name =:chs_name:','bind'=>array('chs_name'=>$value['child_name'])));
// if (!isset($child_info->id)){
// $not_child[] = $value['index_name'].'-'.$value['child_name'];
// }else {
// $child[$value['index_name']][] = $child_info->name;
// }
// }
// }
}
示例3: getIndexDetail
/**
* @type 不更改
* @method $rt->id $rt->children $rt->name $rt->action
* @param unknown $index_name
*/
public static function getIndexDetail($index_name)
{
self::checkConnect();
return Index::findFirst(array("name = :index_name:", 'bind' => array('index_name' => $index_name), 'hydration' => \Phalcon\Mvc\Model\Resultset\Simple::HYDRATE_ARRAYS, 'cache' => array('key' => 'index_detail_name_' . $index_name)));
}
示例4: getFactorGrideByLevel
public function getFactorGrideByLevel($factor_chs_name = null, $factor_name = null, $level_examines, $project_id)
{
#判斷因子是index還是factor
//按照中文名搜索
if (empty($factor_chs_name)) {
$factor_info = Factor::findFirst(array("name = ?2", 'bind' => array(2 => $factor_name)));
$search = 'Factor.name = ' . "'{$factor_name}'";
//按照英文名搜索
} else {
$factor_info = Factor::findFirst(array("chs_name = ?2", 'bind' => array(2 => $factor_chs_name)));
$search = 'Factor.chs_name = ' . "'{$factor_chs_name}'";
}
if (isset($factor_info->id)) {
//對各層次人群進行得分計算後返回
$rtn_array = array();
foreach ($level_examines as $level_array) {
$result = $this->modelsManager->createBuilder()->columns(array('AVG(FactorAns.ans_score) as score'))->from('Examinee')->inwhere('Examinee.id', $level_array)->join('FactorAns', 'FactorAns.examinee_id = Examinee.id AND Examinee.type =0 AND Examinee.project_id = ' . $project_id)->join('Factor', 'FactorAns.factor_id = Factor.id AND ' . $search)->getQuery()->execute()->toArray();
if (empty($result[0]['score'])) {
$score = 0;
} else {
$score = sprintf('%.2f', $result[0]['score']);
}
$rtn_array[] = $score;
}
return $rtn_array;
}
//按照中文名搜索
if (empty($factor_chs_name)) {
$index_info = Index::findFirst(array(" name = ?2", 'bind' => array(2 => $factor_name)));
$search = 'Index.name = ' . "'{$factor_name}'";
//按照英文名搜索
} else {
$index_info = Index::findFirst(array("chs_name = ?2", 'bind' => array(2 => $factor_chs_name)));
$search = 'Index.chs_name = ' . "'{$factor_chs_name}'";
}
if (isset($index_info->id)) {
$rtn_array = array();
foreach ($level_examines as $level_array) {
$result = $this->modelsManager->createBuilder()->columns(array('AVG(IndexAns.score) as score'))->from('Examinee')->inwhere('Examinee.id', $level_array)->join('IndexAns', 'IndexAns.examinee_id = Examinee.id AND Examinee.type =0 AND Examinee.project_id = ' . $project_id)->join('Index', 'IndexAns.index_id = Index.id AND ' . $search)->getQuery()->execute()->toArray();
if (empty($result[0]['score'])) {
$score = 0;
} else {
$score = sprintf('%.2f', $result[0]['score']);
}
$rtn_array[] = $score;
}
return $rtn_array;
}
throw new Exception('no this factor exist!' . print_r($factor_name));
}
示例5: getFactorName
/**
* @usage input 指標名數組 array
* @return 因子名數組 array
*/
public static function getFactorName($index_names)
{
$factor_names = array();
foreach ($index_names as $value) {
$index = Index::findFirst(array('name=?1', 'bind' => array(1 => $value)));
$children_str = $index->children;
$children_type_str = $index->children_type;
$children_array = explode(",", $children_str);
$children_type_array = explode(',', $children_type_str);
$i = 0;
#指標下有子指標
foreach ($children_type_array as $value) {
#子指標下屬的肯定是因子
if ($value == '0') {
$zi = Index::findFirst(array('name=?1', 'bind' => array(1 => $children_array[$i])));
$zi_child_str = $zi->children;
$zi_child_array = explode(",", $zi_child_str);
foreach ($zi_child_array as $value) {
$factor_names[] = $value;
}
} else {
$factor_names[] = $children_array[$i];
}
$i++;
}
}
return array_unique($factor_names);
}
示例6: report
public function report($project_id)
{
$data = new ProjectComData();
$data->project_check($project_id);
$chart = new WordChart();
$project = Project::findFirst($project_id);
//-----------------------------------
\PhpOffice\PhpWord\Autoloader::register();
$this->wordHandle = new \PhpOffice\PhpWord\PhpWord();
// layout
$sectionStyle = array('orientation' => 'portrait', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.9), 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21), 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(29.7), 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(0.8));
//add section
$section = $this->wordHandle->addSection($sectionStyle);
$section->getStyle()->setPageNumberingStart(1);
$header = $section->addHeader();
$header = $header->createTextrun();
$header->addImage('reportimage/logo_2.jpg', array('marginTop' => -1, 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToInch(1), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.98), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.54), 'wrappingStyle' => 'square'));
$header->addText($project->name . "總體分析報告", array('color' => 'red', 'size' => 11), array('lineHeight' => 1, 'alignment' => 'right'));
$footer = $section->addFooter();
$footer->addPreserveText('{PAGE}', array('size' => 10, 'color' => '000000'), array('alignment' => 'center', 'lineHeight' => 1));
//cover part
$paragraphStyle = array('alignment' => 'center', 'lineHeight' => 1.5);
$defaultParagraphStyle = array('lineHeight' => 1.5);
$captionFontStyle = array('name' => 'Microsoft YaHei', 'size' => 22, 'color' => 'red', 'bold' => true);
$section->addTextBreak(6);
$section->addText($project->name . "總體分析報告", $captionFontStyle, $paragraphStyle);
$section->addPageBreak();
//set title style---TOC
$this->wordHandle->addTitleStyle(1, array('size' => 16, 'bold' => true), array('lineHeight' => 1.5));
$this->wordHandle->addTitleStyle(2, array('size' => 15, 'bold' => true), array('lineHeight' => 1.5));
$this->wordHandle->addTitleStyle(3, array('size' => 12, 'bold' => true), array('lineHeight' => 1.5));
//catalog part
$section->addText("目錄", array('color' => 'blue', 'size' => 12), $paragraphStyle);
$section->addTOC(array('size' => 12), \PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE, 1, 3);
$section->addPageBreak();
$captionFontStyle2 = array('name' => 'Microsoft YaHei', 'size' => 18, 'color' => 'red', 'bold' => true);
$section->addText($project->name . "總體分析報告", $captionFontStyle2, $paragraphStyle);
//part1 項目背景
$section->addTitle("一、項目背景", 1);
//-------------------------------------------------------------------------
$examinee = Examinee::find(array('project_id=?1 AND type = 0 ', 'bind' => array(1 => $project_id)));
$examinee = $examinee->toArray();
$examinee_num = count($examinee);
//總人數
$exam_date_start = explode(' ', $project->begintime)[0];
//開始時間
$exam_date_end = explode(' ', $project->endtime)[0];
//結束時間
$min_time = 0;
$total_time = 0;
$level_array = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
foreach ($examinee as $examinee_record) {
if ($min_time == 0 || $min_time > $examinee_record['exam_time']) {
$min_time = $examinee_record['exam_time'];
}
$total_time += $examinee_record['exam_time'];
$level = ReportData::getLevel($examinee_record['id']);
$level_array[$level]++;
}
$min_time_str = null;
foreach (array(3600 => '小時', 60 => '分', 1 => '秒') as $key => $value) {
if ($min_time >= $key) {
$min_time_str .= floor($min_time / $key) . $value;
$min_time %= $key;
}
}
//最短答題時間
$average_time = $total_time / $examinee_num;
$average_time_str = null;
foreach (array(3600 => '小時', 60 => '分', 1 => '秒') as $key => $value) {
if ($average_time >= $key) {
$average_time_str .= floor($average_time / $key) . $value;
$average_time %= $key;
}
}
//平均答題時間
$rate_1 = sprintf('%.2f', $level_array[1] / $examinee_num) * 100 . '%';
//優秀率
$rate_2 = sprintf('%.2f', $level_array[2] / $examinee_num) * 100 . '%';
//良好率
$rate_3 = sprintf('%.2f', $level_array[3] / $examinee_num) * 100 . '%';
//中等率
// ---------------------------------------------------------
$section->addText(" 為了充分開發中青年人才資源,了解中青年人才水平、培養有潛力人才及科技骨幹、選拔一批經驗豐富,德才兼備的中青年高技能人才,北京XXX集團(後簡稱“集團”),采用第三方北京技術交流培訓中心(以下簡稱“中心”)自主研發26年,通過上下、左右、前後六維(簡稱“6+1”)測評技術,對集團" . $examinee_num . "名中青年人才進行了一次有針對性的測評。從" . $exam_date_start . "到" . $exam_date_end . ",在集團培訓中心進行上機測試。規定測評時間為3小時,最短完成時間為" . $min_time_str . ",一般為" . $average_time_str . "左右。 ", $defaultParagraphStyle);
$section->addText(" 測評後進行專家(四位局級以上領導幹部)與中青年人才一對一人均半小時的溝通(簡稱“麵詢”), 這是區別國內所有綜合測評機構的獨有特色。麵詢內容有三:一是根據測評結果按優劣勢分析歸納與評價;二是雙方互動理解與確認測評結果;三是現場解答每位人才提出的問題,並給予針對性、個性化的解決方案與建議。", $defaultParagraphStyle);
$section->addText(" 通過對" . $examinee_num . "位中青年人才綜合統計分析,按優良中差排序結果為:全體優秀率達" . $rate_1 . ",良好" . $rate_2 . "。在測評和專家麵詢後,對全部人才進行了無記名的滿意度調查,參加調查83人,回收有效問卷83份,有效率100%,滿意度100%。(滿意度調查報告詳見附件1) ", $defaultParagraphStyle);
$section->addTitle("1、測評目的", 2);
$section->addTitle("第一、為中青年人才培訓提供科學參考依據", 3);
$section->addText(" 在傳統的人事管理信息係統中,人與人之間的差別隻體現在性別、年齡、職務、工種、學曆、職稱、工作經曆上,而卻忽略了內隱素質能力上的差異。綜合測評可以幫助集團領導了解中青年人才更多重要的信息,為個性化培養與培訓提供科學、準確的依據。在對人才進行精準識別後,還進行了人崗匹配,針對崗位勝任程度和潛質提出了使用與培養的建議。通過本次測評,清晰了集團中青年人才職業心理、職業素質、智體結構、職業能力和發展潛質,為集團下一步的培訓工作提供了科學、客觀、準確的依據。", $defaultParagraphStyle);
$section->addTitle("第二、為中青年人才提供自我認知和自我提升的工具", 3);
$section->addText(" 通過綜合測評,幫助了這些人才全麵、係統、客觀、準確了解自我;通過結合崗位職責一對一麵詢,讓這些人才更加明確自身優勢與劣勢;清晰哪些技能和素質需要進一步培訓,在實際工作中揚長避短,促進自我職業生涯與集團戰略的有機結合。", $defaultParagraphStyle);
$section->addTitle("2、測評流程", 2);
$section->addText(" 綜合測評分為五個階段:", $defaultParagraphStyle);
$section->addText(" 一是測評前準備。這一階段確定測試人才的人數、測評時間、測評內容、測評群體的總體情況;收集測評人才簡曆;編製測評總體需求量表。", $defaultParagraphStyle);
$section->addText(" 二是人機對話測評。通過“6+1”係統綜合測評,人均獲取近1000個定性與定量數據,經過數據處理與統計分析,為專家麵詢提供科學、準確、客觀、真實的測評結果。", $defaultParagraphStyle);
$section->addText(" 三是專家麵詢。這一過程人均半小時,目的是讓有較高領導崗位經曆和複合學科背景的專家依據測評結果,與中青年人才一對一的互動溝通:首先,幫他們清晰自己的優劣勢;其次,為他們排憂解惑;最後,為每位中青年人才梳理出與集團發展匹配的對策。", $defaultParagraphStyle);
$section->addText(" 四是撰寫總體與個體報告。依據對“6+1”大數據分析結果撰寫總體綜合素質分析報告;整合個人測評結果和專家麵詢評價,撰寫每位人才的綜合測評分析報告。", $defaultParagraphStyle);
$section->addText(" 五是匯報與反饋。向集團領導匯報總體與個體測評結果,反饋無記名滿意度調查報告等,針對集團發展戰略和現代人力資源管理提出針對性的建議與對策。", $defaultParagraphStyle);
$section->addTitle("3、技術路徑", 2);
$section->addText(" “中心”的綜合測評係統始於1988年博士研究成果,經曆了26年實踐檢驗,其過程(1)測評地域:北京、上海、天津、廣東、山西、湖南、湖北、陝西、內蒙、海南、浙江、山東、遼寧、河南等省市;(2)年齡:20~68歲;(3)學曆:大專~博士後;(4)職稱:初級~兩院士;(5)職務:初、中級~政府副部長、部隊中將(陸海空);(6)類型:跨國公司高管、各類企業高管與技術人才;(7)測評人數:3萬多人;(8)測評數據:每人925個;(9)獲得榮譽:7次獲國家自然科學基金資助,2次獲航空科學基金資助,4次獲省部級科學技術進步二等獎和管理成果一等獎;在國內外核心刊物發表論文30多篇,專著一本;測評軟件50多套;培養出3名博士、9名碩士;經調查,客戶反映測評準確率高、效果明顯,平均滿意度達97.8%,受到被測評人才和用人單位的普遍歡迎和認可。", $defaultParagraphStyle);
//.........這裏部分代碼省略.........