Jump to content

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 :)
Link to comment
https://forums.phpfreaks.com/topic/10662-drop-clear-tablesfields/
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.
[!--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.
[!--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 :).
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.