avenirer / CodeIgniter-MY_Model

Base model (MY_Model) for the Codeigniter framework.
324 stars 203 forks source link

_set_table_fillable_protected not called if $table is set #266

Closed agung-wete closed 6 years ago

agung-wete commented 7 years ago

i think _set_table_fillable_protected should always called, even when $this->table not empty

https://github.com/avenirer/CodeIgniter-MY_Model/blob/7af1df0204b6741286fc6898c3f874b33767a6e2/core/MY_Model.php#L1930-L1932

    private function _fetch_table()
    {
        if (!isset($this->table))
        {
            $this->table = $this->_get_table_name(get_class($this));
            if (!$this->db->table_exists($this->table)) {
               show_error(
                   sprintf('While trying to figure out the table name, couldn\'t find an existing table named: <strong>"%s"</strong>.<br />You can set the table name in your model by defining the protected variable <strong>$table</strong>.',$this->table),
                   500,
                   sprintf('Error trying to figure out table name for model "%s"',get_class($this))
               );
            }
        }

        $this->_set_table_fillable_protected();

        return TRUE;
    }
svennd commented 6 years ago

Yes, this results in an error if not done. The object $this->fillable remains null that is not allowed for example : (line 163) if (c($field, $this->fillable)) {