unistake Posted November 30, 2010 Share Posted November 30, 2010 Hi all, I am developing a CMS sort of website and during the planning I can see that I will be using a lots of variations of $sql and $results in previous websites I have just re-typed the whole script on every PHP page where they were needed. To keep the scripts a bit tidier this time, I was hoping to get some advice as to the best way to use/manage them. E.g. Should I copy and paste the $sql codes in every PHP page? Should I create a functions.php page and include all the variations of $sql that I will be using all call for them when needed? Or Should I go about it another way!? Thanks for any advice. Quote Link to comment https://forums.phpfreaks.com/topic/220255-advice-using-sqls-frequently/ Share on other sites More sharing options...
Maq Posted November 30, 2010 Share Posted November 30, 2010 I would create a class to handle your SQL. This way you can easily reuse your code. Now, depending on how your code is already structured, it could be a bit of an overhaul, but worth it IMO. Quote Link to comment https://forums.phpfreaks.com/topic/220255-advice-using-sqls-frequently/#findComment-1141426 Share on other sites More sharing options...
unistake Posted November 30, 2010 Author Share Posted November 30, 2010 I have not written a line of code yet. Can you tell me moire about classes to handle SQL - never heard of this - I am an advanced beginner! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/220255-advice-using-sqls-frequently/#findComment-1141429 Share on other sites More sharing options...
Maq Posted November 30, 2010 Share Posted November 30, 2010 I have not written a line of code yet. Can you tell me moire about classes to handle SQL - never heard of this - I am an advanced beginner! Thanks If you Google for this topic (PHP sql database class) then you will find many examples. If you have specific questions I will be more than happy to help. Quote Link to comment https://forums.phpfreaks.com/topic/220255-advice-using-sqls-frequently/#findComment-1141445 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.