mikehaertl\shellcommand\Command::getExecCommand PHP Method

getExecCommand() public method

public getExecCommand ( ) : string | boolean
return string | boolean the full command string to execute. If no command was set with setCommand() or passed to the constructor it will return false.
    public function getExecCommand()
    {
        if ($this->_execCommand === null) {
            $command = $this->getCommand();
            if (!$command) {
                $this->_error = 'Could not locate any executable command';
                return false;
            }
            $args = $this->getArgs();
            $this->_execCommand = $args ? $command . ' ' . $args : $command;
        }
        return $this->_execCommand;
    }

Usage Example

Exemplo n.º 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;
     }
 }
All Usage Examples Of mikehaertl\shellcommand\Command::getExecCommand