protected function prepareConfigurationFile()
    {
        $cnfFile = "[client]\n";
        $cnfParams = array();
        $configurationMapping = array(
            'user'      => 'db_user',
            'password'  => 'db_password',
            'host'      => 'db_host',
            'port'      => 'db_port',
        );

        foreach ($configurationMapping as $key => $param) {
            if ($this->params[$param]) {
                $cnfParams[$key] = $this->params[$param];
            }
        }

        if (!empty($cnfParams)) {
            foreach ($cnfParams as $key => $value) {
                $cnfFile .= "$key = \"$value\"\n";
            }

            $this->filesystem->dumpFile($this->getConfigurationFilePath(), $cnfFile);
            $this->filesystem->chmod([$this->getConfigurationFilePath()], 0600);
            $this->auth = sprintf("--defaults-extra-file=\"%s\"", $this->getConfigurationFilePath());
        }
    }
protected function prepareConfigurationFile()
    {
        $cnfFile = "[client]\n";
        $cnfParams = array();
        $configurationMapping = array(
            'user'      => 'db_user',
            'password'  => 'db_password',
            'host'      => 'db_host',
            'port'      => 'db_port',
        );

        foreach ($configurationMapping as $key => $param) {
            if ($this->params[$param]) {
                $cnfParams[$key] = $this->params[$param];
            }
        }

        if (!empty($cnfParams)) {
            foreach ($cnfParams as $key => $value) {
                $cnfFile .= "$key = \"$value\"\n";
            }

            $this->filesystem->dumpFile($this->getConfigurationFilePath(), $cnfFile);
            $this->filesystem->chmod([$this->getConfigurationFilePath()], 0600);
            $this->auth = sprintf("--defaults-extra-file=\"%s\"", $this->getConfigurationFilePath());
        }
    }
protected function prepareConfigurationFile ( ) { $ cnfFile = "[client]\n" ; $ cnfParams = array ( ) ; $ configurationMapping = array ( 'user' => 'db_user' , 'password' => 'db_password' , 'host' => 'db_host' , 'port' => 'db_port' , ) ; foreach ( $ configurationMapping as $ key => $ param ) { if ( $ this -> params [ $ param ] ) { $ cnfParams [ $ key ] = $ this -> params [ $ param ] ; } } if ( ! empty ( $ cnfParams ) ) { foreach ( $ cnfParams as $ key => $ value ) { $ cnfFile .= "$key = \"$value\"\n" ; } $ this -> filesystem -> dumpFile ( $ this -> getConfigurationFilePath ( ) , $ cnfFile ) ; $ this -> filesystem -> chmod ( [ $ this -> getConfigurationFilePath ( ) ] , 0600 ) ; $ this -> auth = sprintf ( "--defaults-extra-file=\"%s\"" , $ this -> getConfigurationFilePath ( ) ) ; } }
Prepare mysql configuration file for connection
Prepare mysql configuration file for connection