• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error on trying to join tables

Hi all,

Need help, I've tried a lot of things but it doesn't work.
An image is better to understand, here my two tables

So for a simple example, I would like to get all columns from 'client' + column 'name' from 'contact'

My actual function is :
PHP Code:
public function get_client($client_id)

           $query $this->db->get('client');
                 return $query->result();
                 return FALSE;
This function works and I would like to add the column 'name'

I tear my hair I will not have any more :-)

PHP Code:
$query $this->db->select('cl.*, ct.name')
from('client cl')
join('contact ct','cl.client_id = ct.client_id')


CodeIgniter Users Guide

See: The Query Builder join method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

That's what I've done but I was writing :

probably something wrong in the code, but now with your code it's working.
thx u

and I read the doc ^^

P.S. : I thing I know why ! I specified get('client')....

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.