Network_ninja Posted August 18, 2011 Share Posted August 18, 2011 hey guys.... Just have a question Is it advantageous or will do good if i make my tablename as a variable? For example: $table1 = "first_table"; $table2 = "second_table"; Query: $query = @mysql_query("SELECT * FROM $table1 "); or does it still good practice if I write my queries like this: $query = @mysql_query("SELECT * FROM first_table"); tnx everyone.... Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/ Share on other sites More sharing options...
trq Posted August 18, 2011 Share Posted August 18, 2011 It makes no difference at all to MySql. Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1258943 Share on other sites More sharing options...
Network_ninja Posted August 18, 2011 Author Share Posted August 18, 2011 Tnx bro... I am planing to mke my tablenames as variable so that in the future if we need to rename the table we will not be editing a lot of code.... Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1258971 Share on other sites More sharing options...
fenway Posted August 18, 2011 Share Posted August 18, 2011 You shouldn't even need to rename your tables -- don't even give yourslef that option. Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1259080 Share on other sites More sharing options...
Network_ninja Posted August 19, 2011 Author Share Posted August 19, 2011 why? is it bad to rename a table? what if we really need to change the name of it? Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1259214 Share on other sites More sharing options...
fenway Posted August 20, 2011 Share Posted August 20, 2011 Quote why? is it bad to rename a table? what if we really need to change the name of it? You never "really need to" -- don't pick an arbitrary name to begin with. Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1259847 Share on other sites More sharing options...
Network_ninja Posted August 20, 2011 Author Share Posted August 20, 2011 Tnx for the help guys.... Link to comment https://forums.phpfreaks.com/topic/245091-queries-good-practice/#findComment-1259855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.