gpt4 book ai didi

php - 用于搜索用户 token (技能)的 SQL 查询

转载 作者:行者123 更新时间:2023-11-30 23:23:47 25 4
gpt4 key购买 nike

我正在我的网站上构建一个搜索用户技能的搜索系统,这些技能以 token 的形式呈现,用户技能的数据库表如下所示:

 id=> primary id(auto increment), 
user_id=> this is the user id,
competence_nom=> this is the skill name,
competence_id=> this is the skill parent id

所以我想要的是当两个技能(或更多..)属于一个用户时,显示如下:

user name + skill one + skill two

而不是像这样(我现在正在取得的成就)

user name +skill one
user name +skill two

我正在使用 jQuery tokeninput 插件将 token 数据传递到服务器端,我将技能 ID 传递到服务器端,然后在服务器端我展开由 jQuery tokeninput 给出的技能数组:

 $comps=explode(",", $_POST["competences"]); 

然后我把它放在一个 foreach 循环中:

 foreach($comps as $i=>$v){  


}

这就是我得到错误输出的地方:

user name +skill one
user name +skill two

最佳答案

据我目前的了解,这是您的数据模型的问题。

核心问题是您的数据模型必须支持哪些用例,作为其中的一部分,底层查询的效率必须如何。

如果您的技能集非常有限并且需要非常高的性能,您可能想要寻求一种解决方案,其中技能集真正表示为位集。

如果清晰的用户界面和清晰的数据模型是主要目标,而性能可能是次要的,那么人们想到的方法是建立一个关系数据模型,在一个表中包含人员核心数据,在第二个表中分配技能,像这样:

TABLE person
id: (auto increment)
name: (or split into first name etc)
email: (etc, you get the idea)

TABLE skill
id: (auto increment)
description:

TABLE personskill
personid: (reference to person.id)
skillid: (reference to skill.id)

然后,通过关系数据库查询,系统将回答将哪些技能分配给哪个人的问题。

SELECT skillid FROM personskill WHERE personid = (id of person you're looking at)

关于php - 用于搜索用户 token (技能)的 SQL 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14316873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com