public function getQuestions($params = "",$page= "all", $count=false){
$this->db->query('SELECT questions.questions_id, questions.question_description,
questions.question_explanation, questions.created_date,
questions.updated_date, questions.is_active,
diffLevels.difficulty_levels_title
FROM '.TBL_QUESTION.' as questions
INNER JOIN '.TBL_DIFFICULTY_LEVELS.' as diffLevels
ON questions.fk_difficulty_levels_id = diffLevels.preference
WHERE questions.is_active=1');
$Q = $this->db->get();
if ($Q->num_rows() > 0) {
foreach ($Q->result() as $row) {
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
这是我的查询..我做了很多调整,但它不会工作..等待可能的解决方案?感谢
答案 0 :(得分:1)
尝试此查询:
$this->db->select('
questions.questions_id,
questions.question_description,
questions.question_explanation,
questions.created_date,
questions.updated_date,
questions.is_active,
diffLevels.difficulty_levels_title
');
$this->db->from("questions");
$this->db->join("diffLevels",'questions.fk_difficulty_levels_id = diffLevels.preference' , 'inner');
$this->db->where("questions.is_active",1);
$query=$this->db->get();
$data=$query->result_array();
//echo $this->db->last_query();
//echo "<hr/>";
//echo "<pre>";
//print_r($query);
//exit;
我直接使用表名作为“问题”和“diffLevels”,请相应更改。