Welcome Guest, Not a member yet? Register   Sign In
join failed
#1

Hello,

I wonder why I cannot see the result of this after join.  If I comment out the join it does return a value.  I  do have wishlists table with user_id column and users table with id column.  I do have similar id.  I wonder why it does not return any value?



UserModel.php


    function enduser_table($data)
    {
        //merchants.id = orders.merchant_id

        $this->db->select('*');
        $this->db->from('users');
        $this->db->join('wishlists', 'wishlists.user_id = users.id');
        //$this->db->join('orders', 'orders.user_id = users.id');
        $this->db->where('id', $data);
        
        return $this->db->get()->result();

    }
" If I looks more intelligence please increase my reputation."
Reply
#2

If you need a specific type of JOIN you can specify it via the third parameter of the function.
Options are: left, right, outer, inner, left outer, and right outer.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I try using :


function enduser_table($data)
    {
     
        $this->db->select('*');
        $this->db->from('users');
        $this->db->join('wishlists', 'wishlists.user_id = users.id', left);
        $this->db->where('id', $data);
                
        return $this->db->get()->result();

    }

I already try left, right and inner and none of them works.
" If I looks more intelligence please increase my reputation."
Reply
#4

Do you have have error reporting on?

You might have encountered a ambiguous error...

try
$this->db->where('users.id', $data);
or change users by the table the ID should be from.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB