parse() public static method

public static parse ( $command, $params )
Example #1
0
 /**
  * @param string $command Shell command template to execute,
  *                takes :configkey notation
  * @param string $filename Filename of patch or dump file
  * @return string Command to execute
  */
 protected function getCliCommand($command, $filename)
 {
     $config = $this->getAdapter()->getConfig();
     $params = array();
     $params['filename'] = $filename;
     $keys = array('host', 'port', 'username', 'password', 'dbname', 'charset', 'filename');
     foreach ($keys as $key) {
         if (isset($config[$key]) && !empty($config[$key])) {
             $params[$key] = escapeshellarg($config[$key]);
         }
     }
     return DbPatch_Core_Parser::parse($command, $params);
 }
Example #2
0
 public function testCompleteCommand()
 {
     $command = "mysql -h{host} {%port%}-P{port} {%port%}-u{username} {%password%}-p{password} {%password%}--default-character-set={charset} {dbname} < {filename} 2>&1";
     $params = array('host' => 'localhost', 'username' => 'joe', 'password' => 'secret', 'charset' => 'utf-8', 'dbname' => 'mydatabse', 'filename' => 'patch-0001.sql');
     $this->assertEquals('mysql -hlocalhost -ujoe -psecret --default-character-set=utf-8 mydatabse < patch-0001.sql 2>&1', DbPatch_Core_Parser::parse($command, $params));
 }