Skip to content

Commit

Permalink
Add MySQL App (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored and derimagia committed Jan 11, 2017
1 parent a58eedc commit aee5fa8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/Apps/MySQLApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Pantheon\TerminusPancakes\Apps;

/**
* Open Site database in MySQL CLI
*/
class MySQLApp extends PancakesApp {
/**
* {@inheritdoc}
*/
public $aliases = ['mysql'];

/**
* {@inheritdoc}
*/
public $app = 'MySQL';

/**
* - App Location Candinates
*/
public $app_location;

public function open(){
$cmd = join(' ', [
'mysql',
'-h ' . $this->escapeShellArg($this->connection_info['mysql_host']),
'-P ' . $this->escapeShellArg($this->connection_info['mysql_port']),
'-u ' . $this->escapeShellArg($this->connection_info['mysql_username']),
'-p' . $this->escapeShellArg($this->connection_info['mysql_password']),
$this->connection_info['mysql_database'],
]);

$process = proc_open(
$cmd,
[
0 => STDIN,
1 => STDOUT,
2 => STDERR,
],
$pipes
);
proc_close($process);
}

/**
* Validates the app can be used
*/
public function validate() {
if ($this->isWindows()) {
return FALSE;
}

$this->app_location = 'mysql';
return $this->which($this->app_location);
}
}

0 comments on commit aee5fa8

Please sign in to comment.