Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring the models #566

Open
rnomals opened this issue Dec 21, 2020 · 1 comment
Open

Refactoring the models #566

rnomals opened this issue Dec 21, 2020 · 1 comment

Comments

@rnomals
Copy link
Collaborator

rnomals commented Dec 21, 2020

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

@ov1n
Copy link
Owner

ov1n commented Dec 26, 2020

Thank you sir . the insert functions and select functions have been implemented in the model.php already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants