donjakobo/A3M

account_details_model->update issue, with fix and explanation

Closed this issue · 3 comments

When account_details_model->update is called to update the table a3m_account_details and there are no changes, the update database call never fires. Since $this->db is stateful, it affects the next database call. This may be a mysql/mysqli issue since I am using mysqli (as set in my config/database.php settings). To avoid this problem, I added a check that there is actually something to update before the update is called:

starting at line 121:

// Update
if ($this->get_by_account_id($account_id))
{
    if ( count($attributes) != 0 )  {   // <--- new code here
        $this->db->where('account_id', $account_id);
        $this->db->update('a3m_account_details', $attributes);
    }  // <--- new code here
...

Could you submit a PR request with the changes so you can get the credit? Also which version?

I'm not really clear on what that means. Do you create a branch for me? If so, let me know and I'll do it. I have 3 issues with solutions so far I can roll in.

You can read about it here: http://help.github.com/send-pull-requests/ or https://github.com/donjakobo/A3M/blob/ci3-beta/contributing.md
Since you have 3 fixes it would be best to do a pull request.