Remove use of MySQL transactions
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?php defined('BASEPATH') || exit("No direct script access allowed");
|
<?php defined('BASEPATH') || exit('No direct script access allowed');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User model.
|
* User model.
|
||||||
@@ -409,18 +409,17 @@ class User extends CI_Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* Updates a user.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @param string $id
|
||||||
|
* @param array $data
|
||||||
|
* @return boolean Returns TRUE if the update was successful.
|
||||||
*/
|
*/
|
||||||
public function update($id, $data) {
|
public function update($id, $data) {
|
||||||
$user = $this->getUserByID($id);
|
$user = $this->getUserByID($id);
|
||||||
|
|
||||||
$this->db->trans_begin();
|
|
||||||
|
|
||||||
if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) {
|
if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) {
|
||||||
$this->db->trans_rollback();
|
$this->messages->add(_('The entered username is already in use.'), 'error');
|
||||||
$this->access->setError('account_creation_duplicate_username');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,32 +431,18 @@ class User extends CI_Model {
|
|||||||
$this->db->update('users', $data, array('id' => $id));
|
$this->db->update('users', $data, array('id' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->trans_status() === false) {
|
return $this->db->affected_rows() > 0;
|
||||||
$this->db->trans_rollback();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->trans_commit();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the specified user.
|
* Deletes a specified user.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @param string $id
|
||||||
|
* @return boolean Returns TRUE if the deletion was successful.
|
||||||
*/
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->db->trans_begin();
|
|
||||||
|
|
||||||
$this->db->delete('users', array('id' => $id));
|
$this->db->delete('users', array('id' => $id));
|
||||||
|
return $this->db->affected_rows() > 0;
|
||||||
if ($this->db->trans_status() === false) {
|
|
||||||
$this->db->trans_rollback();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->trans_commit();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user