Jump to content

search trough entire database


surion

Recommended Posts

hi,

i m pretty sure this already exists, tough i just don't find it.

what i m looking for is a script that can search for a value trough an entire database, not depending on      table names or field names.

 

for example lets say i have "a database", i do not know what fields or tables are in there. i know somewhere there is a field with the value "blablabla", the code should return a tablename and a fieldname where the value "blablabla" was found

Link to comment
Share on other sites

You'd want to start with a SHOW TABLES, then loop through the resulting tables and do a DESCRIBE on each. Dump the table names and fields into a 2d array, and then loop through each table and do SELECT count(*) FROM $tableName WHERE $fieldName = $value.

 

Make sense? It should be pretty straightforward. Not sure if there is a more efficient way of doing it, but that should certainly work.

Link to comment
Share on other sites

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.