public function get_post_info(){
$this->db->select('users.id as idautor,
users.first_name, post.active, post.id, post.titulo,
post.preco, post.user, post.data, post.img, post.conteudo');
$this->db->from('post');
$this->db->where('post.active',1);
$this->db->where('post.isf',0);
$this->db->join('users', 'users.id = post.user');
$this->db->limit(8);
$this->db->order_by('post.data','DESC');
return $this->db->get()->result();
}
public function get_post_photo(){
$this->db->select('users.id as idautor, users_pub_main_picture.url as url,
users.first_name, post.active, post.id, post.titulo,
post.preco, post.user, post.data, post.img, post.conteudo');
$this->db->from('post');
$this->db->where('post.active',1);
$this->db->where('post.isf',0);
$this->db->join('users', 'users.id = post.user');
$this->db->join('users_pub_main_picture', 'users_pub_main_picture.pub_id = post.id');
return $this->db->get()->result();
}
我试图在不同行中的codeigniter中获取帖子主图像,并在视图中显示帖子信息,但是如果图像行中有2个主图像,codeigniter会显示重复的帖子,内容相同且图像不同>
答案 0 :(得分:0)
public function get_post_info()
{
$this->db->select('users.id as idautor,
users.first_name, post.active, post.id, post.titulo,
post.preco, post.user, post.data, post.img as firstimage, post.conteudo');
$this->db->from('post');
$this->db->where('post.active',1);
$this->db->where('post.isf',0);
$this->db->join('users', 'users.id = post.user');
$this->db->limit(8);
$this->db->order_by('post.data','DESC');
return $this->db->get()->result();
}
public function get_post_photo(){
$this->db->select('users.id as idautor, users_pub_main_picture.url as url,
users.first_name, post.active, post.id, post.titulo,
post.preco, post.user, post.data, post.img as secondimage, post.conteudo');
$this->db->from('post');
$this->db->where('post.active',1);
$this->db->where('post.isf',0);
$this->db->join('users', 'users.id = post.user');
$this->db->join('users_pub_main_picture', 'users_pub_main_picture.pub_id = post.id');
return $this->db->get()->result();
}