From 401812acbd84485d24a431884916c7674584e8a3 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 04:13:04 +0200 Subject: [PATCH] Remove use of MySQL transactions --- application/models/user.php | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/application/models/user.php b/application/models/user.php index d70574d..91b50dc 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -1,4 +1,4 @@ -getUserByID($id); - $this->db->trans_begin(); - if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) { - $this->db->trans_rollback(); - $this->access->setError('account_creation_duplicate_username'); + $this->messages->add(_('The entered username is already in use.'), 'error'); return false; } @@ -432,32 +431,18 @@ class User extends CI_Model { $this->db->update('users', $data, array('id' => $id)); } - if ($this->db->trans_status() === false) { - $this->db->trans_rollback(); - return false; - } - - $this->db->trans_commit(); - return true; + return $this->db->affected_rows() > 0; } /** - * 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) { - $this->db->trans_begin(); - $this->db->delete('users', array('id' => $id)); - - if ($this->db->trans_status() === false) { - $this->db->trans_rollback(); - return false; - } - - $this->db->trans_commit(); - return true; + return $this->db->affected_rows() > 0; } /**