I followed on online tutorial to create an OOP login/registration system for my website. I am trying to reuse the code to connect to the same database but a different table. The code below is the method to update the users table.
public function update($fields = array(), $id = null) {
if(!$id && $this->isLoggedIn()) {
$id = $this->data()->id;
}
if(!$this->_db->update('users', $id, $fields)) {
throw new Exception('There was a problem updating.');
}
}
What I want to be able to do is update any table using the same code.
I have tried changing 'users' to $table and then using declaring $table = 'destinations' in the relevant pages but get the errors " Undefined variable: table" and "Uncaught exception 'Exception' with message 'There was a problem updating.' "