php script for dropping tables.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
viziony
Forum Newbie
Posts: 1
Joined: Wed Apr 21, 2010 9:21 pm

php script for dropping tables.

Post by viziony »

Hi all!

I am a beginner to php and also mysql. I have to do some maintenance on a database and I open to any suggestion / feedback you all can provide. I have a huge user table which also references user tables. Table "User" contains "User1" table , "User2" table, etc. I can query to give me results for users that have not logged in since January of 2010. How do I go about using the results to drop the tables ? Would this be easier via php script or mysql ? I cannot find a way to do this via mysql and I don't have a backup of my database since it has over 400k tables. And cannot seem to list the files within the database directory (or it would take a really long time). I need to do some cleanup and that is why I am asking

Thank you for reading and providing any valuable information!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php script for dropping tables.

Post by requinix »

First, your terminology. Tables have rows, not more tables. What you want are to delete rows that match a condition.
Also there aren't files in a database. You may be storing file contents in tables or you may be storing just the names.

To delete rows from a table in MySQL,

Code: Select all

DELETE FROM tablename WHERE condition
Your task is to figure out what the "condition" should be.

And what are you trying to "clean up"?
Post Reply