<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

/**
 * Description of inlineeditor_model
 *
 * @author Igor Ratsun
 */
class inlineeditor_model extends CI_Model
{
    public function save($id_resource_type_resource, $id_lan, $data = '')
    {
        $this->db
                ->where('id_resource_type_resource', (int) $id_resource_type_resource)
                ->where('id_lan', (int) $id_lan)
                ->update('resource_type_resource_translate', array('content' => $data));
        
        return ($this->db->affected_rows() > 0) ? 1 : 0;
    }

    public function fetch_content($id_resource_type_resource, $id_lan)
    {
        $data = $this->db
            ->select('content')
            ->where('id_resource_type_resource', (int) $id_resource_type_resource)
            ->where('id_lan', (int) $id_lan)
            ->get('resource_type_resource_translate')
            ->row_array();

        return (!empty($data['content'])) ? $data['content'] : '';
    }
}
