1<?php 2 3/** 4 * `SET` statement. 5 */ 6 7namespace PhpMyAdmin\SqlParser\Statements; 8 9use PhpMyAdmin\SqlParser\Components\OptionsArray; 10use PhpMyAdmin\SqlParser\Components\SetOperation; 11use PhpMyAdmin\SqlParser\Statement; 12 13/** 14 * `SET` statement. 15 * 16 * @category Statements 17 * 18 * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ 19 */ 20class SetStatement extends Statement 21{ 22 /** 23 * The clauses of this statement, in order. 24 * 25 * @see Statement::$CLAUSES 26 * 27 * @var array 28 */ 29 public static $CLAUSES = array( 30 'SET' => array( 31 'SET', 32 3 33 ), 34 '_END_OPTIONS' => array( 35 '_END_OPTIONS', 36 1 37 ) 38 ); 39 40 /** 41 * Possible exceptions in SET statment. 42 * 43 * @var array 44 */ 45 public static $OPTIONS = array( 46 'CHARSET' => array( 47 3, 48 'var', 49 ), 50 'CHARACTER SET' => array( 51 3, 52 'var', 53 ), 54 'NAMES' => array( 55 3, 56 'var', 57 ), 58 'PASSWORD' => array( 59 3, 60 'expr', 61 ), 62 'SESSION' => 3, 63 'GLOBAL' => 3, 64 'PERSIST' => 3, 65 'PERSIST_ONLY' => 3, 66 '@@SESSION' => 3, 67 '@@GLOBAL' => 3, 68 '@@PERSIST' => 3, 69 '@@PERSIST_ONLY' => 3, 70 ); 71 72 public static $END_OPTIONS = array( 73 'COLLATE' => array( 74 1, 75 'var', 76 ), 77 'DEFAULT' => 1 78 ); 79 80 /** 81 * Options used in current statement. 82 * 83 * @var OptionsArray[] 84 */ 85 public $options; 86 87 /** 88 * The end options of this query. 89 * 90 * @var OptionsArray 91 * 92 * @see static::$END_OPTIONS 93 */ 94 public $end_options; 95 96 /** 97 * The updated values. 98 * 99 * @var SetOperation[] 100 */ 101 public $set; 102 103 /** 104 * @return string 105 */ 106 public function build() 107 { 108 $ret = 'SET ' . OptionsArray::build($this->options) 109 . ' ' . SetOperation::build($this->set) 110 . ' ' . OptionsArray::build($this->end_options); 111 112 return trim($ret); 113 } 114} 115