I try to design multilingual site. In my view files I put some variables that depends on language have different content. I have a function that parsing view file and put variables in array. Than I connect to DB and get content. Originally, question was about optimize this query to get content. But, maybe, whole approach was wrong? Here is DB tables:
FIELDS languages_short_name, char(3), PRI variable, varchar(20),PRI content, longtext LANGUAGES short_name, char(3), PRI name, varchar(20)
Here is the query:
$subquery = 'Select \'' .
implode('\' as variable union Select \'', $var_array) . '\'';
$query = sprintf( "Select tmp.variable,
if(fields.content is NULL , '%s', fields.content) as content FROM fields
RIGHT JOIN (%s) tmp
ON tmp.variable = fields.variable
AND fields.languages_short_name = '%s'", 'not defined', $subquery, $lang );