• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/update_class.php
  • Класс: CUpdater
  • Вызов: CUpdater::TableExists
function TableExists($tableName)
{
	global $DB;

	if (!in_array("DATABASE", $this->callType))
		return false;

	$tableName = preg_replace("/[^A-Za-z0-9%_]+/", "", $tableName);
	if ($tableName == '')
		return false;

	if ($this->dbType == "MYSQL")
		$strSql = "SHOW TABLES LIKE '".strtolower($DB->ForSql($tableName))."'";
	elseif ($this->dbType == "ORACLE")
		$strSql = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME LIKE UPPER('".strtoupper($DB->ForSql($tableName))."')";
	elseif ($this->dbType == "MSSQL")
		$strSql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '".strtoupper($DB->ForSql($tableName))."'";
	elseif ($this->dbType == "PGSQL")
		$strSql = "SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename LIKE '".strtolower($DB->ForSql($tableName))."'";
	else
		$strSql = "";

	$dbResult = $DB->Query($strSql);
	if ($dbResult->Fetch())
		return true;
	else
		return false;
}