Created
November 17, 2015 15:42
-
-
Save nklatt/7ae00417df32a4f0485e to your computer and use it in GitHub Desktop.
Loop over all tables in a database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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