db->query('SELECT que-6ren">
gpt4 book ai didi

php - 加入查询在 Codeigniter 中不起作用

转载 作者:行者123 更新时间:2023-11-29 02:44:32 25 4
gpt4 key购买 nike

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;

}

这是我的查询..我做了很多调整但它不会工作..等待可能的解决方案?谢谢

最佳答案

试试这个查询:

$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;

我直接使用表名作为“questions”和“diffLevels”,请相应更改。

关于php - 加入查询在 Codeigniter 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44795256/

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