Repository navigation
Expand file tree
/
Copy pathProcessor.php
More file actions
executable file
·119 lines (103 loc) · 2.9 KB
/
Copy pathProcessor.php
File metadata and controls
executable file
·119 lines (103 loc) · 2.9 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Database\Query\Processors;
use Hyperf\Database\Query\Builder;
use Hyperf\Database\Schema\Column;
class Processor
{
/**
* Process the results of a "select" query.
*
* @param array $results
* @return array
*/
public function processSelect(Builder $query, $results)
{
return $results;
}
/**
* Process an "insert get ID" query.
*
* @param string $sql
* @param array $values
* @param string $sequence
* @return int
*/
public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
{
$query->getConnection()->insert($sql, $values);
$id = $query->getConnection()->getPdo()->lastInsertId($sequence);
return is_numeric($id) ? (int) $id : $id;
}
/**
* Process the results of a tables query.
*/
public function processTables(array $results): array
{
return array_map(static function ($result) {
$result = (object) $result;
return [
'name' => $result->name,
'schema' => $result->schema ?? null, // PostgreSQL and SQL Server
'size' => isset($result->size) ? (int) $result->size : null,
'comment' => $result->comment ?? null, // MySQL and PostgreSQL
'collation' => $result->collation ?? null, // MySQL only
'engine' => $result->engine ?? null, // MySQL only
];
}, $results);
}
/**
* Process the results of a column listing query.
*/
public function processColumnListing(array $results): array
{
return $results;
}
/**
* @return Column[]
*/
public function processColumns(array $results): array
{
$columns = [];
foreach ($results as $item) {
$columns[] = new Column(...array_values($item));
}
return $columns;
}
/**
* Process the results of an indexes query.
*/
public function processIndexes(array $results): array
{
return $results;
}
/**
* Process the results of a views query.
*/
public function processViews(array $results): array
{
return array_map(function ($result) {
$result = (object) $result;
return [
'name' => $result->name,
'schema' => $result->schema ?? null, // PostgreSQL and SQL Server
'definition' => $result->definition,
];
}, $results);
}
/**
* Process the results of a foreign keys query.
*/
public function processForeignKeys(array $results): array
{
return $results;
}
}