首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >codeigniter中数据库记录获取问题

codeigniter中数据库记录获取问题
EN

Stack Overflow用户
提问于 2014-01-23 22:31:31
回答 2查看 69关注 0票数 0
代码语言:javascript
复制
$param = $posts['cnv_post_id']; //$posts['cnv_post_id']holds the current post id 
$comments = $this->post_model->get_comments($param);

在模型中:-

代码语言:javascript
复制
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。

EN

回答 2

Stack Overflow用户

发布于 2014-01-23 22:33:33

下面是从表单中获取帖子的方法:

代码语言:javascript
复制
$param = $this->input->post('cnv_post_id');

尝试输出$this->db->last_query()并将其提供给我们

票数 1
EN

Stack Overflow用户

发布于 2014-01-23 22:46:30

你试试吧。

代码语言:javascript
复制
$param = $this->input->post('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(); 

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21311037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档