[eluser]ibnclaudius[/eluser]
I don`t want to get the events from the same user_id...
Here what I have:
Code:
$query = $this->db->select($this->_table['events'] . '.id, ' . $this->_table['events'] . '.title, ' . $this->_table['events'] . '.date, ' . $this->_table['users'] . '.username AS user_username, ' . $this->_table['colleges'] . '.username AS college_username')
->from($this->_table['events'])
->join($this->_table['users_colleges'], $this->_table['users_colleges'] . '.user_id = ' . $user_id, 'INNER')
->join($this->_table['colleges'], $this->_table['colleges'] . '.id = ' . $this->_table['events'] . '.college_id AND ' . $this->_table['colleges'] . '.id = ' . $this->_table['users_colleges'] . '.college_id', 'INNER')
->join($this->_table['users'], $this->_table['users'] . '.id = ' . $this->_table['events'] . '.user_id', 'INNER')
->get();
if ($query->num_rows() > 0) return $query->result_array();
return FALSE;
Return this error:
Quote:Unknown column '1' in 'on clause'
SELECT `events`.`id`, `events`.`title`, `events`.`date`, `users`.`username` AS user_username, `colleges`.`username` AS college_username FROM (`events`) INNER JOIN `users_colleges` ON `users_colleges`.`user_id` = `1` INNER JOIN `colleges` ON `colleges`.`id` = `events`.`college_id` AND colleges.id = users_colleges.college_id INNER JOIN `users` ON `users`.`id` = `events`.`user_id`
The problem is with the quotes in 1, without it works... But I don`t know how to remove this ''