理论中的对抗 [英] MATCH AGAINST in Doctrine
本文介绍了理论中的对抗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现如果我在Doctrine中使用MATCH AGAINST与WHERE语法不会替代传递的参数。例如,如果我运行以下代码
$
I found that if I use MATCH AGAINST in Doctrine with WHERE syntax does not replace the parameters passed. For example if I run the following code $
q = Doctrine_Query::create()
->select('*')
->from('TourismUnit tu')
->where('FALSE');
if ($keywords) {
$keywords_array = $this->parse_keywords($keywords);
for ($i = 0; $i < sizeof($keywords_array); $i++)
$q->orWhere("MATCH (name, description) AGAINST ('?*' IN BOOLEAN MODE)", $keywords_array[$i]);
}
没有找到任何结果。
如果他们使用字符串连接似乎工作。
does not find any results. And if they use the string concatenation seems to work.
$q->orWhere("MATCH (name, description) AGAINST ('".$keywords_array[$i]."*' IN BOOLEAN MODE)");
我使用Doctrine 1.2.2。
I use Doctrine 1.2.2.
有谁知道为什么不在执行sql表达式之前替换参数?
Does anyone know why not replace the parameters before executing the sql expression?
推荐答案
使用单引号导致问题, br>
将其转换为使用 concat(',?,*)
the use of single quote causing the problem,
convert it to use concat("'", ?, "*'")
这篇关于理论中的对抗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文