Skip to content

Instantly share code, notes, and snippets.

@ftassi
Created June 21, 2011 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftassi/1037520 to your computer and use it in GitHub Desktop.
Save ftassi/1037520 to your computer and use it in GitHub Desktop.
<?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