<?
defined('BASEPATH') OR exit('No direct script access allowed');

class m_relation_article extends CI_Model{

	// 생성자, 해당 모델이 생성될때 항상 실행되는 초기화작업
	function __construct(){
		parent::__construct();

        $this->load->database();
        $this->load->library('session');
	}


	#---------------------------------------------------------------------------
    # PURPOSE :	list
    # CREATE  :	2018-04-16
    #---------------------------------------------------------------------------
	function relation_article_join_news_list($req_data){
	    # request
        $content_type   = $req_data['content_type'];
        $content_idx    = $req_data['content_idx'];

        $this->db->select('b.*, (select homepage from press where is_del="N" and idx=b.press_idx) as press_homepage');
        $this->db->where('a.content_idx', $content_idx);
        $this->db->where('a.content_type', $content_type);
        $this->db->where('b.is_del', 'N');
        $this->db->from('relation_article as a');
        $this->db->join('news as b', 'b.idx = a.relation_article_idx');
        $this->db->order_by('a.idx',  'asc');
        $res = $this->db->get();
        $row = $res->result_array();
        
        return $row;
    }

    #---------------------------------------------------------------------------
    # PURPOSE :	list
    # CREATE  :	2018-04-28
    #---------------------------------------------------------------------------
	function relation_article_join_column_list($req_data){
	    # request
        $content_type   = $req_data['content_type'];
        $content_idx    = $req_data['content_idx'];

        $this->db->where('a.content_idx', $content_idx);
        $this->db->where('a.content_type', $content_type);
        $this->db->where('b.is_del', 'N');
        $this->db->from('relation_article as a');
        $this->db->join('column as b', 'b.idx = a.relation_article_idx');
        $this->db->order_by('a.idx',  'asc');
        $res = $this->db->get();
        $row = $res->result_array();

        return $row;
    }




}
?>
