本文整理汇总了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);
}
示例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);
}