本文整理匯總了PHP中models\User::updateId方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::updateId方法的具體用法?PHP User::updateId怎麽用?PHP User::updateId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::updateId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
public function edit($param)
{
$edit_id = $param[0];
$user_model = new User();
if (isset($_POST) && !empty($_POST)) {
$artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_modified' => time());
$artistArray = Gump::xss_clean($artistArray);
$artistArray = Gump::sanitize($artistArray);
$update_id = $user_model->updateId($artistArray, $edit_id);
//UPLOAD ATTACHMENT
if ($_FILES["image"]["tmp_name"] != '') {
//upload image into uploads folder
Upload::setName($slug . time());
Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
$update_data = array('user_image' => Upload::getFileName('images'));
if ($this->user_model->updateId($update_data, $edit_id)) {
Session::set('success', 'Artist record edited');
} else {
Session::set('error', 'operation fails');
}
}
if ($update_id > 0) {
Session::set('success', 'Artist record edited');
Url::redirect('artist');
} else {
Session::set('error', 'operation fails');
}
}
$this->data['user_data'] = $user_model->find($edit_id);
View::rendertemplate('header', $this->data);
View::rendertemplate('sidebar', $this->data);
View::render('artist/artist.add', $this->data);
View::rendertemplate('footer', $this->data);
}
示例2: editprofile
public function editprofile()
{
$this->data['title'] = 'Edit Profile';
$user_model = new \Models\User();
$this->data['user'] = Session::get('user');
$this->data['user'] = $user_model->find(Session::get('user')->user_id);
if (isset($_POST['user_firstname']) && !empty($_POST['user_firstname'])) {
if (count($_POST['dance_category']) > 3) {
$this->data['error'] = 'Dance category cannot exceed 3, Please correct';
} else {
$user_firstname = $_POST['user_firstname'];
$user_lastname = $_POST['user_lastname'];
$user_email = $_POST['user_email'];
$user_phone = $_POST['user_phone'];
$user_gender = $_POST['user_gender'];
$user_bio = $_POST['user_bio'];
$dance_category = $_POST['dance_category'];
$user_slug = Url::generateSafeSlug($user_firstname . $this->data['user']->user_id . $user_lastname);
//delete all user's dancer's category first
$delete = $userdance_model->delete(array('user_dance_user_id' => $this->data['user']->user_id), 5);
//insert dance category
if (count($_POST['dance_category']) > 0) {
foreach ($dance_category as $value) {
$dance_category_count = 0;
$insert_dance_category = $userdance_model->create(array('user_dance_user_id' => $this->data['user']->user_id, 'user_dance_category_id' => $value));
$dance_category_count++;
}
}
//update user db
$update_array = array('user_firstname' => $user_firstname, 'user_lastname' => $user_lastname, 'user_email' => $user_email, 'user_bio' => $user_bio, 'user_gender' => $user_gender, 'user_slug' => $user_slug, 'user_phone' => $user_phone);
$update_array = Gump::xss_clean($update_array);
$update_array = Gump::sanitize($update_array);
$update_id = $user_model->updateId($update_array, $this->data['user']->user_id);
//UPLOAD ATTACHMENT
if ($_FILES["image"]["tmp_name"] != '') {
//upload image into uploads folder
Upload::setName($slug . uniqid());
Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
$image_name = Upload::getFileName('images');
$update_data = array('user_image' => $image_name);
$update_img = $this->user_model->updateId($update_data, $this->data['user']->user_id);
if ($update_img > 0) {
Session::set('success', 'Profile Updated!');
Url::redirect('user');
} else {
$this->data['error'] = 'Operation Fails!';
}
}
if ($update_id > 0) {
Session::set('success', 'Profile Updated!');
Url::redirect('user');
} else {
$this->data['error'] = 'Operation Fails!';
}
if (isset($dance_category_count) && $dance_category_count > 0) {
Session::set('success', 'Dance Category Updated!');
Url::redirect('user');
} else {
$this->data['error'] = 'Operation Fails!';
}
}
}
$this->data['dance_category'] = \models\category::section('dance');
$user_dance_category = \models\userdance::category($this->data['user']->user_id);
foreach ($user_dance_category as $item) {
$this->data['user_dance_category'][] = $item->category_id;
}
View::rendertemplate('header', $this->data);
View::render('workspace/workspace.editprofile', $this->data);
View::rendertemplate('footer', $this->data);
}