Jump to content


Photo

Drop, Clear Tables/Fields


  • Please log in to reply
6 replies to this topic

#1 DaVuLf

DaVuLf
  • Members
  • PipPipPip
  • Advanced Member
  • 124 posts

Posted 28 May 2006 - 08:39 PM

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 :)

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 May 2006 - 09:07 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 DaVuLf

DaVuLf
  • Members
  • PipPipPip
  • Advanced Member
  • 124 posts

Posted 28 May 2006 - 09:13 PM

[!--quoteo(post=377919:date=May 28 2006, 05:07 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 28 2006, 05:07 PM) View Post[/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.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 May 2006 - 01:05 AM

OK -- still, it's just issuing commands; you can write whatever wrapper you desire.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 DaVuLf

DaVuLf
  • Members
  • PipPipPip
  • Advanced Member
  • 124 posts

Posted 29 May 2006 - 01:09 AM

[!--quoteo(post=377954:date=May 28 2006, 09:05 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 28 2006, 09:05 PM) View Post[/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 :).

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 May 2006 - 07:18 AM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 DaVuLf

DaVuLf
  • Members
  • PipPipPip
  • Advanced Member
  • 124 posts

Posted 29 May 2006 - 12:41 PM

Oh, okay, no problem man. Thanks for the help :).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users