pb1uk Posted March 10, 2011 Report Share Posted March 10, 2011 (edited) Hello all, I would say by now i'm fairly familiar with PHP and have made a few database driven sites using PHP and MySQL. However as i'm sure some will know it becomes increasingly frustrating have sql and php code dotted all over the place. With my last site it became a bit of a pain. I'm about to start a new project so thought it was about time i learnt to do object oriented php. I've done a couple of starter tutorials (inc stefans on here - very good starting point by the way) and want to take it a bit further. I basically want to create classes for the tables of my databases and have all the queries i am going to use in there so they're all in one place. Does anyone know of any resources or good tutorials for this kind of thing? I've found a couple, but i'm i'm looking for something specifically related to oo php and mysql. Thanks in advance pb1uk Edited March 10, 2011 by pb1uk Quote Link to comment Share on other sites More sharing options...
BeeDev Posted March 10, 2011 Report Share Posted March 10, 2011 I don't really know good tutorials. But I could suggest one thing, which would help you keep your code organised. MVC - Model -> View -> Controller (http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) It's a nice architecture, and a way of sorting your PHP files so you separate the display from processing. Joomla and other popular CMS's use this approach. Personally, I think if you keep all your SQL in one class, it's kinda counter-intuitive to the whole Object Oriented approach. An SQL statement for a particular object should be generated within that object, not coming from another class. But that's not really a restriction, there's nothing stopping you from doing it this way My 2cents. Quote Link to comment Share on other sites More sharing options...
pb1uk Posted March 10, 2011 Author Report Share Posted March 10, 2011 Thanks i'll read up on that. I want to have seperate classes for the different db tables e.g. user class, post class etc, so ideally i want to have my sql for each table grouped together but kept seperate from other tables, if that makes sense. Quote Link to comment Share on other sites More sharing options...
jstern Posted March 10, 2011 Report Share Posted March 10, 2011 Sounds like Zend Framework would be your best friend. This site has some good introductions and explainantions. Check the official sites (of course) as well Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.