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


PHP Members::findFirst方法代碼示例

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


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

示例1: add_photoAction

 public function add_photoAction($id = null)
 {
     $userSession = $this->session->get('userSession');
     $id = $userSession['id'];
     $member = Members::findFirst($id);
     if (!$member) {
         $this->response->redirect('biz/add_photo/' . $userSession['id']);
     }
     $photos = MemberPhotos::find(array('member_id = "' . $id . '"', 'order' => 'id DESC'));
     $this->view->setVars(['photos' => $photos, 'member' => $member]);
     // POST
     if ($this->request->isPost() && $this->request->hasFiles() == true) {
         //ini_set('upload_max_filesize', '64M');
         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/member/' . $newFileName;
                 // img/business_member ?
                 $filePath = 'img/member/';
                 // img/business_member ?
                 //$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) {
             $memberPhotos = new MemberPhotos();
             $memberPhotos->created = date('Y-m-d H:i:s');
             $memberPhotos->modified = date('Y-m-d H:i:s');
             $memberPhotos->member_id = $userSession['id'];
             $memberPhotos->file_path = $filePath;
             $memberPhotos->filename = $newFileName;
             $memberPhotos->caption = $this->request->getPost('caption');
             if (count($photos) > 0) {
                 $memberPhotos->primary_pic = 'No';
             } else {
                 $memberPhotos->primary_pic = 'Yes';
                 $userSession['primary_pic'] = $filePath . $newFileName;
                 $this->session->set('userSession', $userSession);
             }
             if ($memberPhotos->create()) {
                 return $this->response->redirect('biz/add_photo/' . $id);
             } else {
                 // if member photos creation is failed.
                 $this->view->disable();
                 print_r($memberPhotos . getMessages());
             }
         }
     }
 }
開發者ID:hinjanobara,項目名稱:mbimages,代碼行數:67,代碼來源:BizController.php

示例2: newAction

 public function newAction()
 {
     if ($this->request->isPost()) {
         $messages = $this->formValidate();
         if (count($messages)) {
             $this->view->disable();
             $errorMsg = '';
             foreach ($messages as $msg) {
                 $errorMsg .= $msg . "<br>";
             }
             $this->flash->error('<button type="button" class="close" data-dismiss="alert">×</button>' . $errorMsg);
             return $this->response->redirect('job/new/');
         } else {
             $this->view->disable();
             echo "validation is either failed or passed";
         }
         $userSession = $this->session->get("userSession");
         $jobs = new Jobs();
         $jobs->created = date('Y-m-d H:i:s');
         $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->create()) {
             $id = $jobs->id;
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New job has been created');
             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) {
                     $jobLogos = new JobLogos();
                     $jobLogos->created = date('Y-m-d H:i:s');
                     $jobLogos->modified = date('Y-m-d H:i:s');
                     $jobLogos->member_id = $userSession['id'];
                     $jobLogos->job_id = $id;
                     $jobLogos->file_path = $filePath;
                     $jobLogos->filename = $newFileName;
                     if ($jobLogos->create()) {
                     }
                 }
             }
             return $this->response->redirect('job/view/' . $id);
         }
     }
     $member = Members::findFirst($userSession['id']);
     $this->view->setVar('member', $member);
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $jobCategories = JobCategories::find();
     $this->view->setVar('jobCategories', $jobCategories);
 }
開發者ID:hinjanobara,項目名稱:mbimages,代碼行數:89,代碼來源:JobController.php

示例3: cookie_login

 public function cookie_login()
 {
     if (isset($_COOKIE['mid']) && isset($_COOKIE['e']) && isset($_COOKIE['token'])) {
         $id = $this->decrypt($_COOKIE['mid']);
         $email = $this->decrypt($_COOKIE['e']);
         $token = $this->decrypt($_COOKIE['token']);
         $member = Members::findFirst(array('id = "' . trim($id) . '"', 'email = "' . trim($email) . '"'));
         //$member =  Members::findFirst(array('id= "'.$id.'"', 'email="Yes"'));
         if ($member == true && $this->security->checkHash($token, $member->cookie_token)) {
             $userSession = get_object_vars($member);
             $userSession['type'] = 'Member';
             $profilePic = MemberPhotos::findFirst(array('member_id="' . $userSession['id'] . '"', 'primary_pic="Yes"'));
             $userSession['primary_pic'] = $profilePic->file_path . $profilePic->filename;
             return $this->session->set('userSession', $userSession);
         }
     }
 }
開發者ID:hinjanobara,項目名稱:mbimages,代碼行數:17,代碼來源:ControllerBase.php

示例4: viewAction

 public function viewAction($id = null)
 {
     $jobs = Jobs::findFirst($id);
     if (!$jobs) {
         return $this->response->redirect('jobs/search_jobs');
     }
     $this->view->setVar('jobs', $jobs);
     $member = Members::findFirst($jobs->member_id);
     $this->view->setVar('member', $member);
 }
開發者ID:hinjanobara,項目名稱:mbimages,代碼行數:10,代碼來源:JobController.php


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