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

class Mymodel extends Cad_model
{

    private $TABELAS = [
        'cad_cadastro' => 'Cadastro',
        ];
    
    function __construct() {
       parent::__construct();
       $this->ini();
   }

    function ini()
    {
        foreach ($this->TABELAS as $tb=>$name)
        {
            $get    = "sget$name";
            $gets   = "sget$name"."s";
            $insert = "supdate$name";
            $update = "supdate$name";
            $delete = "sdelete$name";
            
            $this->$get = function($where = []){
                return $this->getRow($tb, $where);
            };
            $this->$gets = function($where = []){
                return $this->getResult($tb, $where);
            };
            $this->$insert = function($data){
                return $this->insert($tb, $data);
            };
            $this->$update = function($id, $data){
                $this->db->where($this->getPrimaryKey($tb), $id);
                return $this->update($tb, $data);
            };
            $this->$delete = function($id){
                $this->db->where($this->getPrimaryKey($tb), $id);
                return $this->delete($tb);
            };
        }
    }
    
}