Search text in fields in every table of a MySQL database

前端 未结 24 1584
梦谈多话
梦谈多话 2020-11-22 06:23

I want to search in all fields from all tables of a MySQL database a given string, possibly using syntax as:

SELECT * FROM * WHERE * LIKE \'%stuff%\'
         


        
24条回答
  •  渐次进展
    2020-11-22 06:55

    There is a nice library for reading all tables, ridona

    $database = new ridona\Database('mysql:dbname=database_name;host=127.0.0.1', 'db_user','db_pass');
    
    foreach ($database->tables()->by_entire() as $row) {
    
    ....do
    
    }
    

提交回复
热议问题