-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a58eedc
commit aee5fa8
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |