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.... Quote Link to comment 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. Quote Link to comment 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.... Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2011 Share Posted August 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
Network_ninja Posted August 20, 2011 Author Share Posted August 20, 2011 Tnx for the help guys.... 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.