CakePHP HTML qoute编码问题 [英] CakePHP HTML qoute encoding issues
问题描述
我正在使用cakephp 1.3。我在字符编码中发现问题。我有两个模型关键字和组,以使关键字属于组。我想做的是在模型关键字中执行全文查询。
I’m working on cakephp 1.3. I’m finding issue in character encoding. I’ve two model Keyword and Group, such that Keyword belongs to Group. What I’m trying to do is to perform full text query in model Keyword.
function geParentKeyword($keyword) {
//$keyword = *Acupuncturist*; Assuming this as input
$match = html_entity_decode("MATCH(Keyword.keyword) AGAINST (\"".trim($keyword)."\" IN BOOLEAN MODE)" );
return $this->find('first', array('fields' =>array('Group.name'), 'conditions' =>array($match) ));
}
这个查询得到错误的结果。我调试查询,我得到这个
I got wrong results with this query. I debug the query and I got this
SELECT `Group`.`name`
FROM `keywords` AS `Keyword`
LEFT JOIN `groups` AS `Group` ON (`Keyword`.`group_id` = `Group`.`id`)
WHERE MATCH(`Keyword`.`keyword`) AGAINST ("*Acupuncturist*" IN BOOLEAN MODE)
LIMIT 1"
查询是完美的但这里的问题是在$ match蛋糕将双引号转换为& quot;
我尝试了html_entity_decode和str_replace()但他们显示相同的查询。
The query is perfect but here the issue is at $match cake converts double quotes into "
I tried with html_entity_decode and str_replace() but they show the same query.
有关详情。
Core.php
Configure::write('App.encoding', 'UTF-8');
Database.php
var $default = array(
….
'encoding' => 'UTF8',
);
预期结果
MATCH(Keyword.keyword) AGAINST (' *Acupuncturist* ' IN BOOLEAN MODE)
请指导我的问题。提前致谢。
Please guide me what is the issue. Thanks in advance.
推荐答案
我自己解决这个问题。
I solve this by myself.
这是由于调试模式,我禁用调试模式。它只工作
It was due to debug mode, I disable debug mode. It works only
Configure::write('debug', 0);
这篇关于CakePHP HTML qoute编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!