$searchTerms = "Blue iconer, Web design, Tester";
$searchTermsArrayTemp = explode(",", $searchTerms); //build an array exploding the string using comma delimiter.
$searchTermsArray = array_map('trim', $searchTermsArrayTemp); //remove the unwanted trailing and leading spaces.
foreach ($searchTermsArray AS $searchTerm)
{
echo $searchTerm;
}
/*
* Blue iconer
* Web design
* Tester
*/
SELECT keyword.word
FROM keyword
INNER JOIN businesskeywords ON businesskeywords.keyword_id = keyword.id
WHERE businesskeywords.business_id = 5
关键词测试仪有哪些业务?
SELECT business.id_business, business.name
FROM business
INNER JOIN businesskeywords ON businesskeywords.business_id = business.id_business
INNER JOIN businesskeywords ON businesskeywords.keyword_id = keyword.id
WHERE keyword.word LIKE '%Tester%'
2条答案
按热度按时间nqwrtyyt1#
获取数据时,分解包含逗号的字符串。就像这样-
7cjasjjr2#
explode()和trim()将为您完成这项工作。
就我个人而言,我不会以这种方式构建数据库,删除/添加/编辑关键字会很痛苦,而且某些关键字可能会在其他业务上冗余(干!)。
我会使用一个单独的关键字表:
关键字
一个企业可以有一个或多个关键字(1,n)
一个关键字可以有一个或多个业务(1,n)
两个表之间有一个多对多关系,这会产生一个中间表
业务关键字
id 5的业务有哪些关键字?
关键词测试仪有哪些业务?