|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace SetBased\Stratum\MySql\Wrapper; |
|
5
|
|
|
|
|
6
|
|
|
use SetBased\Stratum\Common\Wrapper\Helper\WrapperContext; |
|
7
|
|
|
use SetBased\Stratum\Middle\BulkHandler; |
|
8
|
|
|
use SetBased\Stratum\MySql\Exception\MySqlQueryErrorException; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class for generating a wrapper method for a stored procedure selecting a large amount of rows. |
|
12
|
|
|
*/ |
|
13
|
|
|
class BulkWrapper extends MysqlWrapper |
|
14
|
|
|
{ |
|
15
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
16
|
|
|
/** |
|
17
|
|
|
* @inheritdoc |
|
18
|
|
|
*/ |
|
19
|
|
|
protected function enhancePhpDocBlockParameters(array &$parameters): void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->imports[] = BulkHandler::class; |
|
22
|
|
|
|
|
23
|
|
|
$parameter = ['php_name' => '$bulkHandler', |
|
24
|
|
|
'description' => 'The bulk row handler', |
|
25
|
|
|
'php_type' => 'BulkHandler', |
|
26
|
|
|
'dtd_identifier' => null]; |
|
27
|
|
|
|
|
28
|
|
|
$parameters = array_merge([$parameter], $parameters); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
32
|
|
|
/** |
|
33
|
|
|
* @inheritdoc |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function generateMethodBodyWithLobFetchData(WrapperContext $context): void |
|
36
|
|
|
{ |
|
37
|
|
|
// Nothing to do. |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
41
|
|
|
/** |
|
42
|
|
|
* @inheritdoc |
|
43
|
|
|
*/ |
|
44
|
|
|
protected function generateMethodBodyWithLobReturnData(WrapperContext $context): void |
|
45
|
|
|
{ |
|
46
|
|
|
// Nothing to do. |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
50
|
|
|
/** |
|
51
|
|
|
* @inheritdoc |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function generateMethodBodyWithoutLob(WrapperContext $context): void |
|
54
|
|
|
{ |
|
55
|
|
|
$this->throws(MySqlQueryErrorException::class); |
|
56
|
|
|
|
|
57
|
|
|
$context->codeStore->append(sprintf("\$this->executeBulk(\$bulkHandler, 'call %s(%s)');", |
|
58
|
|
|
$context->phpStratumMetadata['routine_name'], |
|
59
|
|
|
$this->getRoutineArgs($context))); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
63
|
|
|
/** |
|
64
|
|
|
* @inheritdoc |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function getDocBlockReturnType(WrapperContext $context): string |
|
67
|
|
|
{ |
|
68
|
|
|
return 'void'; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
72
|
|
|
/** |
|
73
|
|
|
* @inheritdoc |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function getReturnTypeDeclaration(WrapperContext $context): string |
|
76
|
|
|
{ |
|
77
|
|
|
return ': void'; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
//---------------------------------------------------------------------------------------------------------------------- |
|
84
|
|
|
|