-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequestHandler.php
43 lines (36 loc) · 1.39 KB
/
RequestHandler.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
<?php
/**
* Class RequestHandler
*/
class RequestHandler
{
/**
* @param array $post
*/
public static function handle(array $post){
// var_dump(($post));
try {
$host = $post['host'];
$port = $post['port'];
$username = $post['username'];
$password = $post['password'];
$dbname = $post['dbname'];
$executeTheQueries = isset($post['execute']) ? true : false;
$reorderer = new Reorderer($host,$username,$password,$dbname,$port,false);
$startColumns = isset($post['start_columns']) ? $post['start_columns'] : null;
$endColumns = isset($post['end_columns']) ? $post['end_columns'] : null;
$dbTables = isset($post['tables_to_adjust']) ? $post['tables_to_adjust'] : null;
if(count(array_intersect($startColumns,$endColumns)) > 0) {
throw new Exception('You cannot have the same column in both Start and End sequences');
}
if($dbTables !== null){
echo json_response(['queries'=>$reorderer->reorderTables($startColumns,$endColumns,$dbTables)]);
} else {
echo json_response(['dbTables'=>$reorderer->getAllDbTables()]);
}
} catch (Exception $e) {
// var_dump($e->getMessage());
echo json_response($e->getMessage(),500);
}
}
}