Welcome Guest, Not a member yet? Register   Sign In
Model method not inserting data into database
#1

Hey everyone,

I am really having a hard time figuring out something that looks so strange.

Here is what I want to do: each time a user updates profile using the "update" method in ion_auth, I am logging user activity in the database in a table called "activity". I created a model with a method "log" that has two arguments: UserId and the ActivityMessage.

When I call this "log" method in the user controller 'changepassword' method, it works fine. It inserts the activity to the table. BUT when I call this method inside an if statement that updates user profile, the "log" method gets called successfully BUT never inserts data to the "activity" table. However, the auto-increment ID of the activity table gets incremented if I manually insert the row into the database.

The following works (log method inserts data successfully):
PHP Code:
if ($this->ion_auth_model->changepassword($identity$current_password$password))
{
    
//log user activity
    
$this->activity_model->log_activity($this->ion_auth->user()->row()->id'changed password.');
    
redirect('user/profile','refresh');


BUT the following will NOT insert data to database (however the log method gets called):
PHP Code:
if($this->ion_auth_model->update($id$data)) {
    
$this->activity_model->log_activity($this->ion_auth->user()->row()->id'changed profile data.');
    
redirect('user/profile','refresh');


I even created a helper function to log user activity in the database, so I called the helper function inside the if($this->ion_auth_model->update($id, $data)) {...} block, but STILL it did not populate the table. But if I call that function in the same controller in the ion_auth change password method, it successfully logs data.

Sorry for the long description. But I am really pulling my hair on this!! I tried tons of ways to find out why it does not work!

Please help!!
Reply


Messages In This Thread
Model method not inserting data into database - by cirox - 08-25-2015, 04:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB