Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
trigger.php
1
<?php
2
namespace
Bitrix\Perfmon\Sql
;
3
4
use
Bitrix\Main\NotSupportedException
;
5
6
class
Trigger
extends
BaseObject
7
{
17
public
static
function
create
(
Tokenizer
$tokenizer)
18
{
19
$name
= $tokenizer->getCurrentToken()->text;
20
$trigger =
new
self
(
$name
);
21
22
$tokenizer->
resetState
();
23
$definition =
''
;
24
while
(!$tokenizer->
endOfInput
())
25
{
26
$definition .= $tokenizer->getCurrentToken()->text;
27
$tokenizer->nextToken();
28
}
29
30
$trigger->setBody($definition);
31
32
return
$trigger;
33
}
34
45
public
static
function
searchTableName
(
Tokenizer
$tokenizer)
46
{
47
$lineToken = $tokenizer->getCurrentToken();
48
while
(!$tokenizer->
endOfInput
())
49
{
50
if
($tokenizer->getCurrentToken()->upper ===
'ON'
)
51
{
52
$tokenizer->nextToken();
53
$tokenizer->skipWhiteSpace();
54
return
;
55
}
56
$tokenizer->nextToken();
57
}
58
throw
new
NotSupportedException
(
'Trigger: table name not found. line: '
. $lineToken->line);
59
}
60
68
public
function
getCreateDdl
($dbType =
''
)
69
{
70
return
$this->body
;
71
}
72
80
public
function
getDropDdl
($dbType =
''
)
81
{
82
switch
($dbType)
83
{
84
case
'MSSQL'
:
85
case
'ORACLE'
:
86
return
'DROP TRIGGER '
.
$this->name
;
87
case
'MYSQL'
:
88
default
:
89
return
'// '
. get_class($this) .
':getDropDdl for database type ['
. $dbType .
'] not implemented'
;
90
}
91
}
92
101
public
function
getModifyDdl
(
BaseObject
$target, $dbType =
''
)
102
{
103
return
[
104
$this->
getDropDdl
($dbType),
105
$target->
getCreateDdl
($dbType),
106
];
107
}
108
}
Bitrix\Main\NotSupportedException
Definition
exception.php:159
Bitrix\Perfmon\Sql\BaseObject
Definition
base_object.php:10
Bitrix\Perfmon\Sql\BaseObject\getCreateDdl
getCreateDdl($dbType='')
Definition
base_object.php:172
Bitrix\Perfmon\Sql\BaseObject\$body
$body
Definition
base_object.php:14
Bitrix\Perfmon\Sql\BaseObject\$name
$name
Definition
base_object.php:13
Bitrix\Perfmon\Sql\Tokenizer
Definition
tokenizer.php:66
Bitrix\Perfmon\Sql\Tokenizer\endOfInput
endOfInput()
Definition
tokenizer.php:159
Bitrix\Perfmon\Sql\Tokenizer\resetState
resetState()
Definition
tokenizer.php:117
Bitrix\Perfmon\Sql\Trigger
Definition
trigger.php:7
Bitrix\Perfmon\Sql\Trigger\getCreateDdl
getCreateDdl($dbType='')
Definition
trigger.php:68
Bitrix\Perfmon\Sql\Trigger\create
static create(Tokenizer $tokenizer)
Definition
trigger.php:17
Bitrix\Perfmon\Sql\Trigger\searchTableName
static searchTableName(Tokenizer $tokenizer)
Definition
trigger.php:45
Bitrix\Perfmon\Sql\Trigger\getModifyDdl
getModifyDdl(BaseObject $target, $dbType='')
Definition
trigger.php:101
Bitrix\Perfmon\Sql\Trigger\getDropDdl
getDropDdl($dbType='')
Definition
trigger.php:80
Bitrix\Perfmon\Sql
Definition
base_object.php:2
modules
perfmon
lib
sql
trigger.php
Создано системой
1.10.0