random1 Posted July 20, 2009 Share Posted July 20, 2009 Hey All, What is best practice for SQL queries in OOP in PHP? Is it best to have them all in one class, say 'sql.php' or 'database.php' or have them split up into methods for classes (user.php etc)? Quote Link to comment https://forums.phpfreaks.com/topic/166616-best-practice-for-sql-queries-location/ Share on other sites More sharing options...
Daniel0 Posted July 20, 2009 Share Posted July 20, 2009 From the way you ask the question, it doesn't sound like you've got a very good grasp of OOP yet, so you might want to focus on that first. You could start with some of the OOP tutorials we have on PHP Freaks. Quote Link to comment https://forums.phpfreaks.com/topic/166616-best-practice-for-sql-queries-location/#findComment-878585 Share on other sites More sharing options...
patrickmvi Posted July 20, 2009 Share Posted July 20, 2009 A lot of it has to do with personal preference. I tend to not like using classes/objects because I feel it adds an additional layer of processing that's not really needed. However, the advantage to using global classes or functions is that you can instantly, globally change the behavior of how your functions work without having to go everywhere to make changes. A good example of this would be for error handling purposes. Quote Link to comment https://forums.phpfreaks.com/topic/166616-best-practice-for-sql-queries-location/#findComment-878586 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.