You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In files created in models, I noticed that $conn=Database::conn(); is included in each and every file, please include that part in the constructor of the model.php; so you can inherit that into all of the files in the model. You can further refactor by writing queries as a separate function in the model.php, for example, you can write delete function inside model.php as follows: public function delete($id , $tableName){ $sql = "DELETE FROM" + $tableName +" WHERE id='"+$id'"; //rest of the code goes here }
Refer to how Codeigniter did this link
The text was updated successfully, but these errors were encountered:
In files created in models, I noticed that $conn=Database::conn(); is included in each and every file, please include that part in the constructor of the model.php; so you can inherit that into all of the files in the model. You can further refactor by writing queries as a separate function in the model.php, for example, you can write delete function inside model.php as follows:
public function delete($id , $tableName){ $sql = "DELETE FROM" + $tableName +" WHERE id='"+$id'"; //rest of the code goes here }
Refer to how Codeigniter did this link
The text was updated successfully, but these errors were encountered: