Welcome Guest, Not a member yet? Register   Sign In
CI 1.7: $db->get() and Join
#1

[eluser]Unknown[/eluser]
As like as this post: http://ellislab.com/forums/viewthread/95148/

My code is
Code:
$this->db->select('user_detail.*, industries.name industry_name');
$this->db->from('user_detail');
$this->db->join('industries', 'industries.id = user_detail.industry', 'left');
$query = $this->db->get_where('user_detail', array('userid'=> $userId));
$detail = $query->row();

But I get error because the translated sql is listed below:
Quote:SELECT user_detail.*, industries.name industry_name
FROM (user_detail, user_detail)
LEFT JOIN industries ON industries.id = user_detail.industry
WHERE userid = 'trustock';
Look the line 2, there are two same table name split by comma. The comma is redundant.
#2

[eluser]henrihnr[/eluser]
[quote author="Derek Hsu" date="1225466660"]As like as this post: http://ellislab.com/forums/viewthread/95148/

My code is
Code:
$this->db->from('user_detail');

$query = $this->db->get_where('user_detail', array('userid'=> $userId));

[/quote]

notice 2 lines of code above..you've defined table twice..
#3

[eluser]Unknown[/eluser]
The same code was ok in 1.6.3.
But it's not work in 1.7.0




Theme © iAndrew 2016 - Forum software by © MyBB