ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
MysqlIfsnopDumper.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public const FILE_NAME = "dump.sql";
24 
25  protected ?string $export_hooks_path;
26 
27  public function __construct(?string $export_hooks_path)
28  {
29  $this->export_hooks_path = $export_hooks_path;
30  }
31 
32  public function createDump(
33  string $host,
34  string $user,
35  string $password,
36  string $name,
37  string $port,
38  string $target
39  ): void {
40  if (!is_null($this->export_hooks_path) && !is_readable($this->export_hooks_path)) {
41  throw new Exception("Export hooks file '$this->export_hooks_path' is not readable.");
42  }
43 
44  try {
45  $dumper = new Ifsnop\Mysqldump\Mysqldump(
46  "mysql:host=$host;port=$port;dbname=$name",
47  $user,
48  $password,
49  ['add-drop-table' => true]
50  );
51  if (!is_null($this->export_hooks_path)) {
53  }
54  $dumper->start($target . "/" . self::FILE_NAME);
55  } catch (\Exception $e) {
56  throw new Exception("Error during sql dump: " . $e->getMessage());
57  }
58  }
59 }
createDump(string $host, string $user, string $password, string $name, string $port, string $target)
__construct(?string $export_hooks_path)