code: 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;
          }
      }
docs: Guess the primary key for current table