I’ve written a object oriented style for a month so far and I’m now wondering which is the right approach with sql queries. So for instance I have function getPlayerData in class. So Which way is better –
1) Do a mysql procedure outside of class and give fetched array to getPlayerData
2) Do all the procedure in class
And If you suggest the second case then should I start every function with global $variable which has the mysqli instance started?
Sorry if I don’t use right terms, you can always correct me. Thanks!
Instead of giving each class function a global variable, you could do something like:
Allowing you to use your object like so:
or