getExecCommand() public méthode

public getExecCommand ( ) : string | boolean
Résultat string | boolean the full command string to execute. If no command was set with setCommand() or passed to the constructor it will return false.
Exemple #1
0
 public function up()
 {
     preg_match('/host=([^;]*)/', $this->db->dsn, $hostMatches);
     $hostName = $hostMatches[1];
     preg_match('/dbname=([^;]*)/', $this->db->dsn, $databaseMatches);
     $databaseName = $databaseMatches[1];
     preg_match('/port=([^;]*)/', $this->db->dsn, $portMatches);
     if (isset($portMatches[1])) {
         $port = $portMatches[1];
     } else {
         $port = "3306";
     }
     $command = new Command($this->mysqlExecutable);
     $command->addArg('-h', $hostName);
     $command->addArg('-P', $port);
     $command->addArg('-u', $this->db->username);
     $command->addArg('--password=', $this->db->password);
     $cmd = $command->getExecCommand() . " \"{$databaseName}\" < \"{$this->file}\"";
     #echo "    ".$cmd . "\n"; // TODO echo only with --verbose
     exec($cmd, $output, $return);
     if ($return !== 0) {
         //var_dump($output, $return);
         return false;
     } else {
         return true;
     }
 }
Exemple #2
0
 /**
  * @return string|bool the command to execute with optional Xfvb wrapper applied. Null if none set.
  */
 public function getExecCommand()
 {
     $command = parent::getExecCommand();
     if ($this->enableXvfb) {
         return $this->xvfbRunBinary . ' ' . $this->xvfbRunOptions . ' ' . $command;
     }
     return $command;
 }
 public function testCanRunCommandWithArguments()
 {
     $command = new Command('ls');
     $command->addArg('-l');
     $command->addArg('-n');
     $this->assertEquals("ls -l -n", $command->getExecCommand());
     $this->assertFalse($command->getExecuted());
     $this->assertTrue($command->execute());
     $this->assertTrue($command->getExecuted());
 }