Skip to content

Instantly share code, notes, and snippets.

@rdobrynin
Created February 18, 2015 09:28
Show Gist options
  • Save rdobrynin/9e5543c3e742d3db7717 to your computer and use it in GitHub Desktop.
Save rdobrynin/9e5543c3e742d3db7717 to your computer and use it in GitHub Desktop.
CI Active records JOIN two tables
<?
public function getProjectUsers($pid) {
$data = array();
$query = $this->db->select('*')
->from('projects')
->join('users', 'projects.uid = users.id')
->where('projects.assign', 0)
->where('projects.pid', $pid)
->get();
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row) {
$data[] = $row;
}
}
else {
$data = false;
}
$query->free_result();
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment