1: | <?php |
2: | /** |
3: | * This code is licensed under AGPLv3 license or Afterlogic Software License |
4: | * if commercial version of the product was purchased. |
5: | * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files. |
6: | */ |
7: | |
8: | namespace Aurora\System\Db; |
9: | |
10: | /** |
11: | * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0 |
12: | * @license https://afterlogic.com/products/common-licensing Afterlogic Software License |
13: | * @copyright Copyright (c) 2019, Afterlogic Corp. |
14: | * |
15: | * @package Api |
16: | * @subpackage Db |
17: | */ |
18: | class Func |
19: | { |
20: | /** |
21: | * @var string |
22: | */ |
23: | protected $sName; |
24: | |
25: | /** |
26: | * @var string |
27: | */ |
28: | protected $sIncParams; |
29: | |
30: | /** |
31: | * @var string |
32: | */ |
33: | protected $sResult; |
34: | |
35: | /** |
36: | * @var string |
37: | */ |
38: | protected $sText; |
39: | |
40: | /** |
41: | * @param string $sName |
42: | * @param string $sText |
43: | */ |
44: | public function __construct($sName, $sIncParams, $sResult, $sText) |
45: | { |
46: | $this->sName = $sName; |
47: | $this->sIncParams = $sIncParams; |
48: | $this->sResult = $sResult; |
49: | $this->sText = $sText; |
50: | } |
51: | |
52: | /** |
53: | * @param IDbHelper $oHelper |
54: | * @param bool $bAddDropFunction = false |
55: | * @return string |
56: | */ |
57: | public function ToString($oHelper, $bAddDropFunction = false) |
58: | { |
59: | $sResult = ''; |
60: | if ($bAddDropFunction) { |
61: | $sResult .= 'DROP FUNCTION IF EXISTS '.$this->sName.';;'.Table::CRLF; |
62: | } |
63: | |
64: | $sResult .= 'CREATE FUNCTION '.$this->sName.'('.$this->sIncParams.') RETURNS '.$this->sResult; |
65: | $sResult .= Table::CRLF.$this->sText; |
66: | |
67: | return trim($sResult); |
68: | } |
69: | } |
70: |