[eluser]codex[/eluser]
Imagine a 'project'-table with, besides the projectdata itself, 3 fields:
- project_creator_id = the id of the person who created the project
- project_client_id = the id of the person for whom the project is done
- project_contractor_id = the id of the person who will realise the project
The project creator can either be the client or the contractor, so at least 2 id's will be the same. I want to show the projects that were NOT created by the user id (uid) in the current session (me), but where I am either the client or contractor.
So in short: how would you say 'give me the rows where either uid is project_client_id or project_contractor_id, but NOT where uid is project_creator_id'
This doesn't work:
Code:
function get_co_projects()
{
$this->db->select('*');
$this->db->from('projects');
$this->db->where('project_client_id', $this->session->userdata('uid'));
$this->db->orwhere('project_contractor_id', $this->session->userdata('uid'));
$this->db->where('project_creator_id !=', $this->session->userdata('uid'));
$query = $this->db->get();
return $query->result();
}
It's basically the OR that screws it up.