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. 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. 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 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. Link to comment https://forums.phpfreaks.com/topic/220255-advice-using-sqls-frequently/#findComment-1141445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.