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