[PHP] Best way to do this?

Soldato
Joined
25 Oct 2006
Posts
5,395
Hello

I'm not extremely experienced with PHP/MySQL but I know the syntax. I need to work out the best way to do this.

I have a database with a list of players for a game, the names they have used, IP addresses, unique IDs etc. I want to create an interface for the database. One main page with a list of all players on the server with the ability to sort the data. Also, individual player pages for each player. It will also need a search feature.

What would be the best way to do this? Hopefully using OOP too...
 
Hmm, well I don't want to go too far down the wrong road.

Would it be correct to use classes for database connection, pagination and sorting then procedural layout for the rest?
 
Be careful with OOP, though; it's very easy to get the wrong end of the stick. When learning OOP it's best to stick to simple applications while you find your feet (i.e. with easily identifiable 'entities' to be represented by classes/objects and actions by methods on those classes). PHP in particular can make learning OOP… interesting.

Also be aware that not everything requires or is suited to OOP. Use the paradigm/pattern appropriate to the task :)
 
Last edited:
Yeah a lot of people make the mistake of fitting a problem into a design pattern they know whereas the problem should dictate the design pattern used.

You should be able to do what you want to do quite easily using a number of approaches. If you are learning then you always have the opportunity to go back and refactor your solution as you become a better programmer.

Sometimes getting ahead of yourself can be counter productive and lead to a slower pace of learning.

You can apply the rough mvc architecture to the problem with a class for database access and functionality. A class for accessing that functionality and routing the program. You are then left with the visual template files and you should be there.
 
Back
Top Bottom