English 中文(简体)
编码协调者多党
原标题:codeigniter multi joins

Hello i有这种结合,但i wanna会加入另一个称为“用户”的标签,并且希望“渗透——稳定”的浏览量,如何做到:

i 是指“WHERE论坛_traad.brugernavn = 用户.profil_billed”类似的东西。

function posts($id)
{
    $this->db->select( *,forum_traad.indhold as traad_indhold,
                       forum_kommentare.indhold as kommentare_indhold,
                        forum_traad.brugernavn as traad_brugernavn,
                        forum_traad.id as traad_id
                        );
    $this->db->from( forum_traad );
    $this->db->join( forum_kommentare ,  forum_kommentare.fk_forum_traad ,  forum_traad.id );
    $this->db->where( forum_traad.id , $id);

    $query = $this->db->get();

    if($query->num_rows > 0)
    {
        return $query->row();
    } else {
        return false;
    }

}
问题回答

你可以提出以下意见:

    $this->db->select( *,forum_traad.indhold as traad_indhold,
                       forum_kommentare.indhold as kommentare_indhold,
                        forum_traad.brugernavn as traad_brugernavn,
                        forum_traad.id as traad_id, users.profil_billed as billed
                        );
   $this->db->from( forum_traad );
   $this->db->join( forum_kommentare ,  forum_kommentare.fk_forum_traad = forum_traad.id );
   $this->db->join( users ,  forum_traad.brugernavn = users.profil_billed );
   $this->db->where( forum_traad.id , $id);
   $query = $this->db->get();

s子的详细文件如下:

rel=“nofollow” http://codeigniter.com/user_guide/database/active_record.html





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签