Jump to content

Archived

This topic is now archived and is closed to further replies.

DaVuLf

Drop, Clear Tables/Fields

Recommended Posts

I was wondering if there is php code that can drop tables or clear all records from them. I'm doing alot of testing, and I need pretty blank or non-existent tables when I start this for real. As such, I need to continually go through phpMyAdmin in order to clear records, and delete tables.

Is there a way to set up a query to DROP table1, table2, table3, table3 or SELECT * FROM table4 DELETE.

Anything similar to those would be great.

Thanks,
DaVuLF :)

Share this post


Link to post
Share on other sites
You can always call a TRUNCATE TABLE statement if you want to empty the table out -- it's faster than DELETE anyway. Same goes for DROP. But I don't know what you mean by PHP code -- it's just a MySQL statement that you need to issue via the DB layer.

Share this post


Link to post
Share on other sites
[!--quoteo(post=377919:date=May 28 2006, 05:07 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 28 2006, 05:07 PM) [snapback]377919[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You can always call a TRUNCATE TABLE statement if you want to empty the table out -- it's faster than DELETE anyway. Same goes for DROP. But I don't know what you mean by PHP code -- it's just a MySQL statement that you need to issue via the DB layer.
[/quote]

Well, I'm using php right. So say I have a file called 'Clear.php' with a submit button on it, I'd like that post action to truncate and drop some tables.

Share this post


Link to post
Share on other sites
OK -- still, it's just issuing commands; you can write whatever wrapper you desire.

Share this post


Link to post
Share on other sites
[!--quoteo(post=377954:date=May 28 2006, 09:05 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 28 2006, 09:05 PM) [snapback]377954[/snapback][/div][div class=\'quotemain\'][!--quotec--]
OK -- still, it's just issuing commands; you can write whatever wrapper you desire.
[/quote]

I don't mean to sound beliggerent, but I just started using PHP the day I registered with this forum. I tried searching for the syntax to do that, but I have no idea.

Thanks anyways :).

Share this post


Link to post
Share on other sites
PHP has a whole set of functions for interfacing with MySQL -- mysql_query() to run queries, mysql_fetch_assoc() to retrieve result sets, etc. There are many resources -- both on this forum, the web, and in the PHP documentation -- that cover this is more detail. I'm not really that good at PHP at all, so I'm not the right guy to ask.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.