PHP Codeigniter-将posts表连接到TOXI标记数据库存储系统
我的模型中的功能如下:PHP Codeigniter-将posts表连接到TOXI标记数据库存储系统,php,codeigniter,activerecord,tags,Php,Codeigniter,Activerecord,Tags,我的模型中的功能如下: function get_all_posts($where='') { $this->load->database(); $this->db->select('blog.title,blog.permalink,blog.content,blog.author,blog.date,COUNT(comments.ID) as commentcount'); $this->db->from('blog');
function get_all_posts($where='')
{
$this->load->database();
$this->db->select('blog.title,blog.permalink,blog.content,blog.author,blog.date,COUNT(comments.ID) as commentcount');
$this->db->from('blog');
if($where!=''){
$this->db->where($where);
}
$this->db->order_by("blog.ID", "desc");
$this->db->join('comments', 'blog.ID = comments.postID','left');
$this->db->group_by('blog.ID');
$query=$this->db->get();
$data=$query->result_array();
return $data;
}
我还有两张桌子-
post_标签:tagID posted
标记:标记ID名称
我一直在玩弄连接,试图获得它,以便与我的所有帖子等一起,返回的变量包含应用于上述帖子的所有标签
我什么都试过了,但几乎没有成功
有人能给点建议吗?
谢谢您没有正确使用$where 在本例中,$where应该是以下形式的数组:
$where = array(
"field_name" => "match_value",
....more conditions.......
);
因此,请确保$where是数组而不是字符串