Created
June 21, 2011 09:26
-
-
Save ftassi/1037520 to your computer and use it in GitHub Desktop.
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 | |
class Altertabletoutf8 extends Doctrine_Migration_Base | |
{ | |
public function up() | |
{ | |
Doctrine::loadModels(sfConfig::get('sf_lib_dir').'/model/doctrine'); | |
$q = Doctrine_Manager::getInstance()->getConnection('doctrine'); | |
foreach (Doctrine::getLoadedModels() as $model) | |
{ | |
$tableName = Doctrine::getTable($model)->getTableName(); | |
$connectionName = Doctrine::getTable($model)->getConnection()->getName(); | |
if ($connectionName == 'doctrine') | |
{ | |
$result = $q->execute(sprintf("ALTER TABLE %s CONVERT TO CHARACTER SET utf8", $tableName)); | |
} | |
} | |
} | |
public function down() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment