0
我遵循在線教程爲我的網站創建一個OOP登錄/註冊系統。我試圖重用代碼連接到相同的數據庫,但不同的表。下面的代碼是更新用戶表的方法。連接到另一個MySQL表OOP PHP
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.');
}
}
我希望能夠做的是使用相同的代碼更新任何表。
我試着將'users'改爲$ table,然後在相關頁面中使用聲明$ table ='destinations',但是得到錯誤「Undefined variable:table」和「Uncaught exception'Exception'更新問題。「 「