Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loop over all tables in a database.
use Illuminate\Database\Capsule\Manager as DB;
$capsule->addConnection(array(
'host' => 'localhost',
'database' => 'information_schema',
'username' => 'usr',
'password' => 'pwd',
'collation' => 'utf8_general_ci',
'charset' => 'utf8',
'driver' => 'mysql',
'prefix' => ''
), 'information_schema');
$table_names =
DB::connection('information_schema')
->table('TABLES')
->select(DB::raw('distinct(TABLE_NAME)'))
->where('TABLE_SCHEMA', '=', 'pmdev_responsive')
->where('TABLE_NAME', 'LIKE', 'ctx_%')
->get();
foreach ($table_names as $table_name) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.