- Модуль: perfmon
- Путь к файлу: ~/bitrix/modules/perfmon/classes/general/query.php
- Класс: CPerfQueryFrom
- Вызов: CPerfQueryFrom::parse
function parse($sql)
{
$sql = CPerfQuery::removeSpaces($sql);
$match = array();
if (preg_match("/^select(.*) from (.*?) (where|group|having|order)/is", $sql, $match))
$this->sql = $match[2];
elseif (preg_match("/^select(.*) from (.*?)$/is", $sql, $match))
$this->sql = $match[2];
else
$this->sql = "";
if ($this->sql)
{
$arJoinTables = preg_split("/(,|inner\s+join|left\s+join)(?=\s+[`"\[\]]{0,1}[a-z0-9_]+[`"\[\]]{0,1})/is", $this->sql);
foreach ($arJoinTables as $str)
{
$table = new CPerfQueryTable;
if ($table->parse($str))
{
$this->tables[] = $table;
}
}
if (count($this->tables) <= 0)
return false;
$tables_regex = "(?:".implode("|", $this->getTableAliases()).")";
/** @var CPerfQueryTable $table */
foreach ($this->tables as $table)
{
$where = new CPerfQueryWhere($tables_regex);
if ($where->parse($table->join))
{
$this->joins = array_merge($this->joins, $where->joins);
}
}
}
return !empty($this->tables);
}