<?php defined('SYSPATH') OR die('No direct access allowed.');

class Model_Album extends Model
{
 	private $album_table;
 	private $genre_table; 


  	public function __construct()
    	{
      		//parent::__construct();
  		$this->album_table = 'albums';
		$this->genre_table = 'genres';
  	}

  	public function read($id)
  	{
		$this->db->where('id', $id);
		$query = $this->db->get($this->album_table);
  		return $query->result_array();
 	}

	public function delete($id)
  	{
		$this->db->delete($this->album_table, array('id' => $id));
  	}

  	public function update($id,$data)
  	{
		$this->db->update($this->album_table, $data, array('id' => $id));
  	}

	public function create($data)
  	{
   		$this->db->insert($this->album_table, $data);
  	}

	public function get_list()
 	{
 		
  		//$this->db2->select('albums.id as id,albums.name as name,albums.author as author, genres.name as genre');
  		//$this->_db2->from($this->album_table);
  		//$this->_db->join($this->genre_table,'genres.id','albums.genre_id');
  		//$query = $this->_db->get();
  		//return $query->result_array();
  		return DB::select()
->from($this->album_table)
->execute()
->as_array();
	}
}
