我正在研究使用PHP的基于内容的过滤算法。我正在尝试使用查询"$user = [$db, "SELECT interest FROM jobseeker WHERE username = '$username'"];"
从表中检索用户数据,它显示警告如注释中所示:
protected function processUser($user)
{
$result = [];
foreach ($user as $tag) {
$result[$tag] = 1.0; //illegal offset type on this line
}
return $result;
}
还在使用查询从表中获取对象
$objects = [$db, "SELECT job_title, category FROM job_data"];
它显示了另一条警告,如注释中所述:
protected function processObjects($objects)
{
$result = [];
foreach ($objects as $object => $tags) {
foreach ($tags as $tag) //invalid argument supplied for foreach()
{
在这种情况下有效的参数是什么? 对于这种情况,我已经尝试过以下查询:
$objects = [($db,"SELECT job_title from jobs") => [$db, "SELECT name FROM categories"]];
它仍然无法正常工作,因为它给此查询带来了意外错误