-
Notifications
You must be signed in to change notification settings - Fork 1
/
using_command_classes_with_connection_params.php
62 lines (47 loc) · 1.33 KB
/
using_command_classes_with_connection_params.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
61
62
<?php
require "../vendor/autoload.php";
use MysqlEIport\Commands\MysqlExport;
use MysqlEIport\Commands\MysqlImport;
$host = "localhost";
$user = "root";
$pass = "";
$name = "empty";
if( isset($_POST) && isset($_FILES['db_file']) ){
$sql_content = $_FILES['db_file']['tmp_name'];
if(file_exists($sql_content))
{
$cmd = new MysqlImport(null, $sql_content);
// Connection Parameters
$cmd->connection($host, $name, $user, $pass);
$cmd->execute();
}else{
throw new \Exception(" $sql_content does not exits", 1);
}
}
elseif ( array_key_exists('export', $_GET) ) {
$export = new MysqlExport(null);
$export->tables = ['migrations'];
$export->backup_name = "test";
// Connection Parameters
$export->connection($host, $name, $user, $pass);
$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 Connection Parameters </h2>
<pre> connection( host_name , database_name, user_name, password) </pre>
<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>