<?php

use app\libraries\CommonHelper;
use app\libraries\DateHelper;
use app\libraries\Tenants;

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

class Tuition_model extends MY_Model {

    use Tenants;

    public $short = "t";
    public $table;
    public $tbl;
    public $database;

//    protected $table = 'mas_tuition';

    public function __construct() {
        parent::__construct();
		$this->database = $this->getTenantNo();
        $this->tbl = 'tuition';
        $this->table = $this->tbl . ' ' . $this->short;
    }

	public function get($mode) {
		$fields = [$this->short . '.id', $this->short . '.mode', $this->short . '.title'];
		$db = $this->load->database($this->database, TRUE);
		$db->select(implode(',', $fields));
		$db->where($this->short . ".mode", $mode);
		return $db->get($this->table_prefix . $this->table)->result_array();
	}

	public function insert($data) {
    	return $this->insertDB($this->database, $this->tbl, $data);
	}

    public function save($param, $id) {
        $this->saveDB($this->database, $this->tbl, $param, $id);
    }

    public function insert_batch($data) {
        $db = $this->load->database($this->database, TRUE);
        $db->insert_batch($this->table_prefix . $this->tbl, $data);
    }

}
