本文介绍了加盟没有给需要的结果使用or_like codeigniter时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$skills = explode(',', 'good listener,topper,leader');
$teacherID = 7;

function search_follower($teacherID, $skills, $limit, $start) {
    $this->db->limit($limit, $start);
    $this->db->select('student_skills.user_id');
    $this->db->from('student_skills');
    $this->db->join('followers', 'followers.student_id = student_skills.user_id', 'FULL JOIN');

    foreach ($skills as $skill) {
        $this->db->like('student_skills.name', $skill);
        $this->db->or_like('student_skills.name', $skill);
    }
    $this->db->where('followers.teacher_id', $teacherID);
    $query = $this->db->get();
    if ($query->num_rows() > 0) {
        foreach ($query->result() as $row) {
            $data[] = $row;
        }
        return $data;
    }
    return false;
}

student_skills表:

student_skills table:

ID 名称 USER_ID

1 礼帽 5

2 领袖 5

3 善于倾听 6

4 拓博 6

跟随表:

ID teacher_id STUDENT_ID

1 7 5

1 7 6

1 7 8

我已经写了上面的模型函数来获取学生证的学生谁遵循特定的老师( $ teacherID ),并指定技能的( $技巧)从student_skills表。

I have written the above model function to fetch student id's of student who follow particular teacher ($teacherID) and have specified skills ($skills) from student_skills table..

当我运行具有多种技能(如:善于倾听,礼帽等)上面的函数或单一技能(例如:礼帽)运行没有显示任何error..but它给了我一切谁拥有指定技能和学生我想只有谁遵循特定的teacher..and的学生有指定的技能。

when i run the above function with multiple skills (ex: good listener, topper etc) or single skills (ex: topper) it runs without showing any error..but it gives me all the students who have the specified skills and i would like to have only the students who follow the particular teacher..and have the specified skills..

但是当我发表意见的 or_like 语句它给了我需要的结果,但多种技能不工作.. 例如:礼帽工作和例如:礼帽,礼帽工作,但例如:礼帽,领导不工作

but when i comment the or_like statement it gives me required result but multiple skills not working.. ex: topper working and ex:topper,topper working but ex: topper,leader not working

我2天在努力解决这个问题..但尚未来到的任何解决方案......

I am struggling from 2 days to solve this.. but not yet came to any solutions....

任何建议或帮助将是一个很大的帮助。在此先感谢。

any suggest or help would be a great help.. thanks in advance.

推荐答案

尝试修改选择的句子。

$this->db->select('student_skills.*, followers.*');

这篇关于加盟没有给需要的结果使用or_like codeigniter时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 08:39