mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
Modifications to make MySQL work
This commit is contained in:
parent
bafabfba05
commit
e51dbea61b
@ -9,19 +9,19 @@ class Mysql extends BackupAbstract
|
|||||||
* @var $pdo \PDO
|
* @var $pdo \PDO
|
||||||
*/
|
*/
|
||||||
private $pdo;
|
private $pdo;
|
||||||
private $tables;
|
protected $tables;
|
||||||
private $host;
|
protected $host;
|
||||||
private $db;
|
protected $db;
|
||||||
private $login;
|
protected $login;
|
||||||
private $pwd;
|
protected $pwd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct(array $config = array()) {
|
public function __construct(array $config = array()) {
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
empty($this->tables) || $this->tables == '*' ? $this->everything() : $this->fromTables($this->tables);
|
|
||||||
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->db, $this->login, $this->pwd);
|
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->db, $this->login, $this->pwd);
|
||||||
|
empty($this->tables) || $this->tables == '*' ? $this->everything() : $this->fromTables($this->tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,7 @@ class Mysql extends BackupAbstract
|
|||||||
if(!empty($tables)) {
|
if(!empty($tables)) {
|
||||||
$this->tables = $tables;
|
$this->tables = $tables;
|
||||||
}
|
}
|
||||||
$this->_streamsToBackup[] = $this->getFromTables();
|
$this->_streamsToBackup[sprintf('db-%s.sql', $this->db)] = $this->getFromTables();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class Mysql extends BackupAbstract
|
|||||||
foreach($this->pdo->query('SHOW TABLES') as $table) {
|
foreach($this->pdo->query('SHOW TABLES') as $table) {
|
||||||
$this->tables[] = $table;
|
$this->tables[] = $table;
|
||||||
}
|
}
|
||||||
$this->_streamsToBackup[] = $this->getFromTables();
|
$this->_streamsToBackup[sprintf('db-%s.sql', $this->db)] = $this->getFromTables();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class Mysql extends BackupAbstract
|
|||||||
$return.= 'INSERT INTO ' . $table . ' VALUES(';
|
$return.= 'INSERT INTO ' . $table . ' VALUES(';
|
||||||
for ($j = 0; $j < $num_fields; $j++) {
|
for ($j = 0; $j < $num_fields; $j++) {
|
||||||
$row[$j] = addslashes($row[$j]);
|
$row[$j] = addslashes($row[$j]);
|
||||||
$row[$j] = preg_replace("\n", "\\n", $row[$j]);
|
// $row[$j] = preg_replace("\n", "\\n", $row[$j]);
|
||||||
if (isset($row[$j])) {
|
if (isset($row[$j])) {
|
||||||
$return.= '"' . $row[$j] . '"';
|
$return.= '"' . $row[$j] . '"';
|
||||||
} else {
|
} else {
|
||||||
@ -95,7 +95,7 @@ class Mysql extends BackupAbstract
|
|||||||
*/
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
// TODO: Implement isValid() method.
|
return !empty($this->_streamsToBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user