<?php

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


class Import_tmodel extends \Ciext\Model\AbstractTableModel
{

    protected $table;
    protected $pkey;
    protected $uniq_field;

    public function set_table($table)
    {
        $this->table = $table;
        $this->pkey = 'id_' . $table;

        return $this;
    }

    public function set_uniq_field($uniq_field)
    {
        $this->uniq_field = $uniq_field;

        return $this;
    }

    public function fetch_all_prepared()
    {
        $exists = $this->set_select($this->pkey . ' as id, ' . $this->uniq_field)->fetch_all();
        return array_combine(array_column($exists, $this->uniq_field), $exists);
    }
}
