-
-
Save sbarrat/a27d4311f4928672544f to your computer and use it in GitHub Desktop.
Alter all tables of a Database width Engine INNODB
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
<?php | |
/** | |
* Created by Ruben Lacasa Mas | |
* User: Ruben Lacasa Mas <ruben@rubenlacasa.es> | |
* Date: 18/10/13 | |
* Time: 12:18 | |
*/ | |
$dbhost = 'hostname'; | |
$dbname = 'dbname'; | |
$dbuser = 'dbuser'; | |
$dbpass = 'dbpassword'; | |
$dsn = 'mysql:dbname='.$dbname.';host='.$dbhost; | |
try { | |
$dbh = new PDO($dsn, $dbuser, $dbpass); | |
} catch (PDOException $e) { | |
echo 'Connection failed: ' . $e->getMessage(); | |
} | |
$sql = "SHOW TABLES"; | |
$query = $dbh->prepare($sql); | |
$query->execute(); | |
$tables = $query->fetchAll(PDO::FETCH_CLASS); | |
foreach ($tables as $table) { | |
$sqlAlter = "ALTER TABLE ".$table->Tables_in_dbname." ENGINE=INNODB;"; | |
$dbh->exec($sqlAlter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment