I FTP source code files and then take a dump of the database (with Drop table option selected) and overwrite live testing server database. But the problem with this is it takes my "junk" testing data along with some required default data. Then I have to manually delete the rows which are not required so that I can give client a clean state. It’d be ideal if I do it through a script which drops existing table and data and create new tables with required default data.
The idea I had was –
$table1 = "sql to create table1";
mysql_query($table1);
$table1_data = "sql to insert default data for table1";
mysql_query($table1_data);
and so on for 20+ different tables …
There must be a better way to handle this. What would you say?
** Update **
Is is possible to write all the queries in one variable and run it –
e.g.
$sql ="
Drop If exists table1
create table1 ....
Insert Into table 1....
Drop If exists table2
create table 2
Insert into table 2
.....
.....
.....
";
mysql_query($sql);
Is there a way to achieve something like above???
I couldn’t get any answer from the community so I am sticking to my own solution ..
I created an array of queries –
and then run each of then in a for loop. Hope it helps someone!