CodeIgniter Forums
Setting up a news section - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Setting up a news section (/showthread.php?tid=47842)



Setting up a news section - El Forum - 12-24-2011

[eluser]Unknown[/eluser]
Hello, I am new to CodeIgniter, I have been using it for a few days but I need some help trying to figure out how stuff works.

On my website I have a news section which gets news from a MySQL database. The problem is that I have to get the authors and comments from two separate tables by using a reference ID in the news table. Is there a way to pass the array containing these IDs from one function to the others within the news model I have set up?

Code:
<?php
class News_model extends CI_Model {
public function __construct()
{
  $this->load->database();
}

public function get_news()
{
  $query = $this->db->query('SELECT * FROM news');
  return $query->result_array();
}

public function get_authors()
{
  //get authors here
}

public function get_comments()
{
  //get comments here
}
}