Model method not inserting data but gets called successfully |
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. It looks like it inserts the row and deletes it automatically? The following works (log method inserts data successfully): PHP Code: if ($this->ion_auth_model->changepassword($identity, $current_password, $password)) PHP Code: if($this->ion_auth_model->update($id, $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!!
If you set up a test on $this->ion_auth_model->update($id, $data) does it work?
I would suspect that if your IF statement is being parsed as TRUE then something other than FALSE is being returned, perhaps an error message? Is your $data constructed with the right information? My first approach would be to validate the $data field, if that was as you intended it to be, is it what ion_auth expected (check the docs) or check the call works by itself. The fact that $this->ion_auth_model->changepassword is working does not say anything about your $this->ion_auth_model->update method. Hope you get it fixed, Best wishes, Paul. (08-25-2015, 04:34 PM)cirox Wrote: Hey everyone, It will not insert any data to your database because you called the UPDATE method. Use the insert function in your model. Code: $data = array('field1' => 'value1', 'field2' => 'value2', ...); Hope it may help!
Enable the profiler and inspect which SQL queries are being fired .
![]() ![]() Learning best practices Rate my post if you found it helpfull |
Welcome Guest, Not a member yet? Register Sign In |