当前位置: 首页>>代码示例>>PHP>>正文


PHP Jobs::findFirst方法代码示例

本文整理汇总了PHP中Jobs::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Jobs::findFirst方法的具体用法?PHP Jobs::findFirst怎么用?PHP Jobs::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jobs的用法示例。


在下文中一共展示了Jobs::findFirst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateAction

 public function updateAction($id = null)
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
         $userSession = $this->session->get("userSession");
         $jobs = Jobs::findFirst($id);
         $jobs->modified = date('Y-m-d H:i:s');
         $jobs->member_id = $userSession['id'];
         $jobs->position = $this->request->getPost('position');
         $jobs->job_category_id = $this->request->getPost('job_category_id');
         $jobs->job_description = $this->request->getPost('job_description');
         $jobs->requirements = $this->request->getPost('requirements');
         $jobs->benefits = $this->request->getPost('benefits');
         $jobs->salary_from = $this->request->getPost('salary_from');
         $jobs->salary_to = $this->request->getPost('salary_to');
         $jobs->company = $this->request->getPost('company');
         $jobs->website = $this->request->getPost('website');
         $jobs->telephone = $this->request->getPost('telephone');
         $jobs->email = $this->request->getPost('email');
         $jobs->street = $this->request->getPost('street');
         $jobs->city = $this->request->getPost('city');
         $jobs->country_id = $this->request->getPost('country_id');
         $jobs->how_to_apply = $this->request->getPost('how_to_apply');
         if ($jobs->update()) {
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New job has been updated');
             if ($this->request->hasFiles() == true) {
                 set_time_limit(1200);
                 $uploads = $this->request->getUploadedFiles();
                 $isUploaded = false;
                 #do a loop to handle each file individually
                 foreach ($uploads as $upload) {
                     #define a “unique” name and a path to where our file must go
                     $fileName = $upload->getname();
                     $fileInfo = new SplFileInfo($fileName);
                     $fileExt = $fileInfo->getExtension();
                     $fileExt = strtolower($fileExt);
                     $newFileName = substr(md5(uniqid(rand(), true)), 0, 10) . date('ymdhis') . '.' . $fileExt;
                     //$fileExt = $upload->getExtension();
                     $fileImageExt = array('jpeg', 'jpg', 'png');
                     //error_log("File Extension :".$fileExt, 0);
                     $fileType = '';
                     $filePath = '';
                     $path = '';
                     //$path = ''.$newFileName;
                     if (in_array($fileExt, $fileImageExt)) {
                         $path = 'img/job/' . $newFileName;
                         $filePath = 'img/job/';
                         //$fileType = 'Image';
                     }
                     #move the file and simultaneously check if everything was ok
                     $upload->moveTo($path) ? $isUploaded = true : ($isUploaded = false);
                 }
                 #if any file couldn't be moved, then throw an message
                 if ($isUploaded) {
                     $jobLogo = JobLogos::findFirst('job_id="' . $id . '"');
                     if ($jobLogo) {
                         //delete previous logo first
                         unlink($jobLogo->file_path . $jobLogo->filename);
                         $jobLogo->created = date('Y-m-d H:i:s');
                         $jobLogo->modified = date('Y-m-d H:i:s');
                         $jobLogo->member_id = $userSession['id'];
                         $jobLogo->job_id = $id;
                         $jobLogo->file_path = $filePath;
                         $jobLogo->filename = $newFileName;
                         if ($jobLogo->update()) {
                         }
                         //before saving the new one
                     } else {
                         $jobLogo = new JobLogos();
                         $jobLogo->created = date('Y-m-d H:i:s');
                         $jobLogo->modified = date('Y-m-d H:i:s');
                         $jobLogo->member_id = $userSession['id'];
                         $jobLogo->job_id = $id;
                         $jobLogo->file_path = $filePath;
                         $jobLogo->filename = $newFileName;
                         if ($jobLogo->create()) {
                         }
                     }
                 }
             }
             return $this->response->redirect('job/view/' . $id);
         }
     }
     $this->view->setVar('job', Jobs::findFirst($id));
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $jobCategories = JobCategories::find();
     $this->view->setVar('jobCategories', $jobCategories);
     $jobLogo = JobLogos::findFirst('job_id="' . $id . '"');
     if ($jobLogo) {
         $jobLogo = $jobLogo->file_path . $jobLogo->filename;
     } else {
         $jobLogo = 'http://placehold.it/200x200';
     }
     $this->view->setVar('jobLogo', $jobLogo);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:96,代码来源:JobController.php

示例2: updateAction

 public function updateAction($id = null)
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
         $userSession = $this->session->get("userSession");
         $jobs = Jobs::findFirst($id);
         $jobs->modified = date('Y-m-d H:i:s');
         $jobs->member_id = $userSession['id'];
         $jobs->position = $this->request->getPost('position');
         $jobs->job_category_id = $this->request->getPost('job_category_id');
         $jobs->job_description = $this->request->getPost('job_description');
         $jobs->requirements = $this->request->getPost('requirements');
         $jobs->benefits = $this->request->getPost('benefits');
         $jobs->salary_from = $this->request->getPost('salary_from');
         $jobs->salary_to = $this->request->getPost('salary_to');
         $jobs->company = $this->request->getPost('company');
         $jobs->website = $this->request->getPost('website');
         $jobs->telephone = $this->request->getPost('telephone');
         $jobs->email = $this->request->getPost('email');
         $jobs->street = $this->request->getPost('street');
         $jobs->city = $this->request->getPost('city');
         $jobs->country_id = $this->request->getPost('country_id');
         $jobs->how_to_apply = $this->request->getPost('how_to_apply');
         if ($jobs->update()) {
             $id = $jobs->id;
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New job has been updated');
             return $this->response->redirect('job/view/' . $id);
         }
     }
     $this->view->setVar('job', Jobs::findFirst($id));
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $jobCategories = JobCategories::find();
     $this->view->setVar('jobCategories', $jobCategories);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:35,代码来源:JobController.php


注:本文中的Jobs::findFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。