Codeigniter 在ci中的“按id获取作业”函数的何处获取作业

Codeigniter 在ci中的“按id获取作业”函数的何处获取作业,codeigniter,Codeigniter,你喜欢这样吗 public function get_active_posted_job_by_id($id){ $Q = $this->db->query("CALL get_active_posted_job_by_id($id)"); if ($Q->num_rows() > 0){ $return = $Q->row(); } else { $return = 0; } $Q-

你喜欢这样吗

public function get_active_posted_job_by_id($id){ 

    $Q = $this->db->query("CALL get_active_posted_job_by_id($id)"); 
    if ($Q->num_rows() > 0){ 
      $return = $Q->row(); 
    } else { 
       $return = 0; 
    } 
    $Q->next_result();
    $Q->free_result(); 
    return $return; 
}

根据您想要做什么,这将只给出一条记录?这用于mysql查询中的模型,但代码仅用于调用函数,但通过id($id)获得“活动”发布的“作业”;函数为无,函数返回所有显示的记录在问题中添加正确的代码。现在很难理解公共函数get_active_posted_job_by_id($id){$Q=$this->db->query(“调用get_active_posted_job_by_id($id)”);if($Q->num_rows()>0){$return Q->row()}否则{$return 0;}$Q->next_result();$Q->free_result();return公共函数count_searched_job_records($param,$param2){$Q=$this->db->query('CALL count_ft_search_job(“'.$param.”,“$param2.””);if($Q->num_rows()>0){$return Q=$row('total');}否则{$return 0;}$Q->next_result();$Q->free_result();return其中count\u ft\u search\u job()函数,此函数不在控制器和模型中
return $this->db->get_where('table_name', ['id' => $id])->row();