使用smarty(Prestashop)为SQL-Statement分配var

时间:2013-01-17 09:41:09

标签: sql smarty prestashop

您好我想在prestashop的模板文件中使用smarty分配一个变量。 我怎么能这样做?

到目前为止我有以下代码:

{$db = DB::getInstance()}
{$id_lang = Context::getContext()->language->id}
{$sql = 'SELECT value FROM ps_feature_value_lang WHERE id_feature_value = 29 AND id_lang = $id_lang'} <- this is not working

1 个答案:

答案 0 :(得分:1)

它不起作用,因为变量在引号内。您需要将字符串与变量连接起来。 没有经过测试,但它应该是这样的:

{$sql = 'SELECT value FROM ps_feature_value_lang WHERE id_feature_value = 29 AND id_lang = '|cat:$id_lang}