search key word in whole Database in mysql and php
Below is the code for key word analysis, $database = 'databasename';$criteria = '*keyword*'; // you can use * and ? as jokers $dbh = new PDO("mysql:host=127.0.0.1;dbname={$database};charset=utf8", 'root', ''); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $tables = $dbh->query("SHOW TABLES"); while (($table = $tables->fetch(PDO::FETCH_NUM)) !== false){ if(strpos($table[0], "cache") === false && strpos($table[0], "sessions") === false && strpos($table[0], "watchdog") === false){ $fields = $dbh->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?"); $fields->execute(array ($database, $table[0])); $ors = array (); while (($field = $fields->fetch(PDO::FETCH_NUM)) !== false) { $ors[] = str_replace("`", "``", $field[0]) . ...