public function applyVariables($variables)
{
// remove comments that encloses a variable placeholder
$query = preg_replace('|/\\*(.*\\[VARIABLE[0-9]*\\].*)\\*/|imsU', '${1}', $this->_query);
// replace variable placeholders with values
$number_of_variables = $this->getVariableCount();
for ($i = 1; $i <= $number_of_variables; $i++) {
$var = '';
if (!empty($variables[$i])) {
$var = $GLOBALS['dbi']->escapeString($variables[$i]);
}
$query = str_replace('[VARIABLE' . $i . ']', $var, $query);
// backward compatibility
if ($i == 1) {
$query = str_replace('[VARIABLE]', $var, $query);
}
}
return $query;
}