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