src/CI_Base_Model.php
protected function _fetch_primary_key()
    {
        if($this->is_base_model_instance()) {
            return;
        }

        if ($this->primary_key == NULL && $this->_database) {
            $this->primary_key = $this->execute_query("SHOW KEYS FROM `" . $this->_database->dbprefix($this->_table) . "` WHERE Key_name = 'PRIMARY'")->row()->Column_name;
        }
    }
protected function _fetch_primary_key()
    {
        if($this->is_base_model_instance()) {
            return;
        }

        if ($this->primary_key == NULL && $this->_database) {
            $this->primary_key = $this->execute_query("SHOW KEYS FROM `" . $this->_database->dbprefix($this->_table) . "` WHERE Key_name = 'PRIMARY'")->row()->Column_name;
        }
    }
protected function _fetch_primary_key ( ) { if ( $ this -> is_base_model_instance ( ) ) { return ; } if ( $ this -> primary_key == NULL && $ this -> _database ) { $ this -> primary_key = $ this -> execute_query ( "SHOW KEYS FROM `" . $ this -> _database -> dbprefix ( $ this -> _table ) . "` WHERE Key_name = 'PRIMARY'" ) -> row ( ) -> Column_name ; } }
Guess the primary key for current table
Guess the primary key for current table