Welcome Guest, Not a member yet? Register   Sign In
Active Record Help?
#3

[eluser]Michael Wales[/eluser]
This prob. doesn't fit your specific schema but it should get you started.

Code:
function episode($id) {
  $this->db->join('authors', 'authors.id = episodes.author_id');
  $this->db->join('sites', 'site.id = episodes.site_id');
  $this->db->select('episodes.*, authors.name as author_name, sites.name as site_name');
  $query = $this->db->get_where('episodes', array('id'=>$id), 1, 0);
  if ($query->num_rows() == 1) {
    $this->data->episode = $query->row();
  } else {
    // We have an invalid episode ID, redirect somewhere
    redirect('');
    return;
  }
}

Code:
<body>
<p>Episode name: &lt;?php echo $episode->name; ?&gt;</p>
<p>Author: &lt;?php echo $episode->author_name; ?&gt;</p>
<p>Site Name: &lt;?php echo $episode->site_name; ?&gt;</p>
&lt;/body&gt;


Messages In This Thread
Active Record Help? - by El Forum - 08-27-2008, 02:08 PM
Active Record Help? - by El Forum - 08-27-2008, 02:12 PM
Active Record Help? - by El Forum - 08-27-2008, 02:20 PM
Active Record Help? - by El Forum - 08-27-2008, 02:39 PM
Active Record Help? - by El Forum - 08-27-2008, 03:04 PM
Active Record Help? - by El Forum - 08-27-2008, 11:08 PM
Active Record Help? - by El Forum - 08-28-2008, 09:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB