<?php
$selfTable = 'songs';
$tables = array(
'types' => 'layout_template_types'
);
$string = '$content AS content,
CONCAT_WS(
".",
$types.alias,
layout_templates.custom_item_id
),
id';
$string = preg_replace_callback('#\$([\w]+)\.([\w]+)#', function($match) use ($tables) {
return '`' . $tables[$match[1]] . '`.`' . $match[2] . '`';
}, $string);
$string = preg_replace_callback('#\$([\w]+)#', function($match) use ($selfTable) {
return '`' . $selfTable . '`.`' . $match[1] . '`';
}, $string);
$string = preg_replace('#([\w]+)\.([\w]+)#', '`\1`.`\2`', $string);
echo $string;
preferences:
36.48 ms | 402 KiB | 5 Q