Welcome Guest, Not a member yet? Register   Sign In
Setting up a news section
#1

[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
}
}




Theme © iAndrew 2016 - Forum software by © MyBB