Search code examples
symfony1pdo

Can I get the database login/password in an action?


I have a symfony action that creates a mysqldump of the database :

public function executeBackup(sfWebRequest $request)
{
    $dump = `mysqldump -u root -proot ec2`;
    $fp = fopen("php://temp", 'r+');
    fputs($fp, $dump);
    rewind($fp);

    $this->setLayout(false);
    header('Content-Type: application/gzip');
    header('Content-Disposition: attachment; filename="db.sql"');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    $this->fichier = stream_get_contents($fp);
}

I've written the database login and password (root/root) in the action, but how can I get them from the yml configuration ?


Solution

  • Look at the code of this plugin, it's pretty self-explanatory.