-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusing_command_classes_with_instance.php
60 lines (44 loc) · 1.2 KB
/
using_command_classes_with_instance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require "../vendor/autoload.php";
use MysqlEIport\Commands\MysqlExport;
use MysqlEIport\Commands\MysqlImport;
$host = "localhost";
$user = "root";
$pass = "";
$name = "empty";
// Mysql Instance
$db_instance = new mysqli($host,$user,$pass,$name);
if( isset($_POST) && isset($_FILES['db_file']) ){
$sql_content = $_FILES['db_file']['tmp_name'];
if(file_exists($sql_content))
{
$cmd = new MysqlImport($db_instance, $sql_content);
$cmd->execute();
}else{
throw new \Exception(" $sql_content does not exits", 1);
}
}
elseif ( array_key_exists('export', $_GET) ) {
$export = new MysqlExport($db_instance);
$export->tables = ['migrations'];
$export->backup_name = "test";
$export->execute();
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Mysql Export and Import Database and Table </title>
</head>
<body>
<h1> Mysql Export and Import Database and Table </h1>
<h2> Using Mysql Command Classes with Mysql Db Instance </h2>
<form enctype="multipart/form-data" method="POST">
<input type="file" name="db_file" />
<button type="submit" name="import">Go</button>
</form>
<form method="GET" >
<button name="export"> Export </button>
</form>
</body>
</html>