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
https://forums.phpfreaks.com/topic/73491-search-trough-entire-database/
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.

Archived

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

×
×
  • 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.