codeigniter中的数据库记录提取问题
问题描述:
我使用以下方法。
$param = $posts['cnv_post_id']; //$posts['cnv_post_id']holds the current post id
$comments = $this->post_model->get_comments($param);
在模型中: -
public function get_comments($cnv_post_id)
{
$get_comments =
$this->db->query('select * from cnv_comment where blog_tbl='.$cnv_post_id.'');
if($get_comments->num_rows > 0)
return $get_comments->result_array();
}
但它不提供结果。但如果我明确地给$ param ='100',其中100是当前的职位id。现在,它返回结果
but its not giving the results. but if I explicitly give $param = '100' where 100 is the current post id. now, its returning the results
答
这是从表单中获取帖子的方式:
This is how you get the post from a form:
$param = $this->input->post('cnv_post_id');
尝试输出 $ this - > db-> last_query()
并提供给我们