403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/perfmon/lib/sql/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/perfmon/lib/sql/constraint.php
<?php
namespace Bitrix\Perfmon\Sql;

class Constraint extends BaseObject
{
	public $columns = [];

	/**
	 * Creates constraint object from tokens.
	 * <p>
	 * If parameter $constraintName is not passed then current position should point to the name of the constraint.
	 *
	 * @param Tokenizer $tokenizer Tokens collection.
	 * @param string $constraintName Optional name of the constraint.
	 *
	 * @return Constraint
	 */
	public static function create(Tokenizer $tokenizer, $constraintName = '')
	{
		if ($constraintName === false)
		{
			$constraintName = '';
		}
		elseif (!$constraintName)
		{
			$constraintName = $tokenizer->getCurrentToken()->text;
			$tokenizer->nextToken();
			$tokenizer->skipWhiteSpace();
		}

		$constraint = new self($constraintName);

		$token = $tokenizer->getCurrentToken();
		$level = $token->level;
		$column = '';
		$constraintDefinition = '';
		do
		{
			if ($token->text === '(' && $token->level == $level)
			{
				$column = '';
			}
			elseif (
				$token->text === ','
				|| ($token->text === ')' && $token->level == $level)
			)
			{
				$column = trim($column);
				if ($column)
				{
					$constraint->columns[] = trim($column);
					$column = '';
				}
			}
			else
			{
				$column .= $token->text;
			}

			if ($token->level == $level && $token->text === ',')
			{
				break;
			}
			if ($token->level < $level && $token->text === ')')
			{
				break;
			}

			$constraintDefinition .= $token->text;

			$token = $tokenizer->nextToken();
		}
		while (!$tokenizer->endOfInput());

		$constraint->setBody($constraintDefinition);

		return $constraint;
	}

	/**
	 * Return DDL for constraint creation.
	 *
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getCreateDdl($dbType = '')
	{
		switch ($dbType)
		{
		case 'MYSQL':
		case 'MSSQL':
		case 'ORACLE':
			return 'ALTER TABLE ' . $this->parent->name . ' ADD CONSTRAINT ' . $this->name . ' ' . $this->body;
		default:
			return '// ' . get_class($this) . ':getCreateDdl for database type [' . $dbType . '] not implemented';
		}
	}

	/**
	 * Return DDL for constraint destruction.
	 *
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getDropDdl($dbType = '')
	{
		switch ($dbType)
		{
		case 'MSSQL':
		case 'ORACLE':
			return 'ALTER TABLE ' . $this->parent->name . ' DROP CONSTRAINT ' . $this->name;
		case 'MYSQL':
		default:
			return '// ' . get_class($this) . ':getDropDdl for database type [' . $dbType . '] not implemented';
		}
	}

	/**
	 * Return DDL for constraint modification.
	 *
	 * @param BaseObject $target Target object.
	 * @param string $dbType Database type (MYSQL, ORACLE or MSSQL).
	 *
	 * @return array|string
	 */
	public function getModifyDdl(BaseObject $target, $dbType = '')
	{
		return [
			$this->getDropDdl($dbType),
			$target->getCreateDdl($dbType),
		];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit