Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
trigger.php
1<?php
2namespace Bitrix\Perfmon\Sql;
3
5
6class 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}
static create(Tokenizer $tokenizer)
Definition trigger.php:17
static searchTableName(Tokenizer $tokenizer)
Definition trigger.php:45
getModifyDdl(BaseObject $target, $dbType='')
Definition trigger.php:101