In sfDoctrinePlugin, you can look at the file: 
sfDoctrineConfigureDatabaseTask.class.php:

  protected function execute($arguments = array(), $options = array())
  {
    // update databases.yml
    if (null !== $options['app'])
    {
      $file = 
sfConfig::get('sf_apps_dir').'/'.$options['app'].'/config/databases.yml';
    }
    else
    {
      $file = sfConfig::get('sf_config_dir').'/databases.yml';
    }

    $config = file_exists($file) ? sfYaml::load($file) : array();

    $config[$options['env']][$options['name']] = array(
      'class' => $options['class'],
      'param' => 
array_merge(isset($config[$options['env']][$options['name']]['param']) ? 
$config[$options['env']][$options['name']]['param'] : array(), array('dsn' 
=> $arguments['dsn'], 'username' => $arguments['username'], 'password' => 
$arguments['password'])),
    );

    file_put_contents($file, sfYaml::dump($config, 4));
  }

So in your action you could do something like:

    $file = sfConfig::get('sf_config_dir').'/databases.yml';
    $config = file_exists($file) ? sfYaml::load($file) : array();
    // get your config options
    $config[$options['env']][$options['name']] = array(
      'class' => $options['class'],
      'param' => 
array_merge(isset($config[$options['env']][$options['name']]['param']) ? 
$config[$options['env']][$options['name']]['param'] : array(), array('dsn' 
=> $arguments['dsn'], 'username' => $arguments['username'], 'password' => 
$arguments['password'])),
    );


Hope that helps :-)

Jamie

p.s. if anyone knows of a better way, please do let me know. I'll be 
interested to hear.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to