private function runCommand($dsn, $command, $data)
    {
        $runner=new CConsoleCommandRunner();
        $runner->commands=array(
            'migrate' => array(
                'class' => $command,
                'dsn' => $dsn,
                'interactive' => 0,
            ),
            'db'=>array(
                'class'=>'CDbConnection',
                'connectionString' => "mysql:host={$dsn['host']};dbname={$dsn['dbname']}",
                'emulatePrepare' => true,
                'username' => $dsn['username'],
                'password' => $dsn['password'],
                'charset' => 'utf8',
            ),
        );
        
        ob_start();
        $modules = array_filter(glob(Yii::app()->getBasePath().'/modules/*', GLOB_ONLYDIR));

        foreach ($modules as $module)
        {
            if (file_exists($module.'/commands'))
                $runner->addCommands($module.'/commands');
        }

        $runner->run($data);
        
        return htmlentities(ob_get_clean(), null, Yii::app()->charset);
    }