<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * 인클루드 class
 *
 * cm_controller: 부모 Class(CI_Controller 확장한 custome class)
 */
include_once (APPPATH.'core/admin/cm_controller.php');

class advertisement_ajax extends CI_Controller {

    var $ad_page_tb_name = 'ad_page'; // 광고 페이지 테이블 이름
    var $ad_code_tb_name = 'ad_detail'; // 광고 코드 테이블 이름

    // find ad_detail by page_name, pos_name
    public function ajax_call_ad_detail_ad_idx(){
        $this->load->database();

        $page_name = $this->input->get_post('page_name');
        $pos_name = $this->input->get_post('pos_name');

        $select ='a.*, b.page_name, b.ad_pos_name';

        
        $where = "b.page_name='".$page_name."' AND b.ad_pos_name= '".$pos_name."'";
        $db_query ="SELECT $select FROM $this->ad_code_tb_name AS a JOIN $this->ad_page_tb_name AS b ON a.ad_idx = b.idx WHERE $where";
        $result = $this->db->query($db_query);
        $data=null;
        foreach($result->result_object() as $row) {
            $data = $row;
            
        }
        echo json_encode($data);
    }
}





