original_string: protected function doInsert()
      {
          /**
           * Run pre-INSERT logic
           */
          $this->beforeInsert();
  
          $data = $this->toArray();
          /**
           * Execute validator logic
           * Can throw ValidatorException
           */
          $this->assert($data);
  
          $table = $this->getTable();
  
          /**
           * Execute the INSERT (this may throw an exception)
           */
          $primaryKey = $table::insert($data);
  
          /**
           * Normalize the result to an array indexed by primary key column(s)
           */
          $tempPrimaryKey = $table->getPrimaryKey();
          $newPrimaryKey = [current($tempPrimaryKey) => $primaryKey];
  
          /**
           * Save the new primary key value in object. The primary key may have
           * been generated by a sequence or auto-increment mechanism, and this
           * merge should be done before the afterInsert() method is run, so the
           * new values are available for logging, etc.
           */
          $this->setFromArray($newPrimaryKey);
  
          /**
           * Run post-INSERT logic
           */
          $this->afterInsert();
  
          /**
           * Update the "clean" to reflect that the data has been inserted.
           */
          $this->clean = $this->toArray();
  
          return $newPrimaryKey;
      }
code: protected function doInsert()
      {
          /**
           * Run pre-INSERT logic
           */
          $this->beforeInsert();
  
          $data = $this->toArray();
          /**
           * Execute validator logic
           * Can throw ValidatorException
           */
          $this->assert($data);
  
          $table = $this->getTable();
  
          /**
           * Execute the INSERT (this may throw an exception)
           */
          $primaryKey = $table::insert($data);
  
          /**
           * Normalize the result to an array indexed by primary key column(s)
           */
          $tempPrimaryKey = $table->getPrimaryKey();
          $newPrimaryKey = [current($tempPrimaryKey) => $primaryKey];
  
          /**
           * Save the new primary key value in object. The primary key may have
           * been generated by a sequence or auto-increment mechanism, and this
           * merge should be done before the afterInsert() method is run, so the
           * new values are available for logging, etc.
           */
          $this->setFromArray($newPrimaryKey);
  
          /**
           * Run post-INSERT logic
           */
          $this->afterInsert();
  
          /**
           * Update the "clean" to reflect that the data has been inserted.
           */
          $this->clean = $this->toArray();
  
          return $newPrimaryKey;
      }
code_tokens: protected function doInsert ( ) { /**
           * Run pre-INSERT logic
           */ $ this -> beforeInsert ( ) ; $ data = $ this -> toArray ( ) ; /**
           * Execute validator logic
           * Can throw ValidatorException
           */ $ this -> assert ( $ data ) ; $ table = $ this -> getTable ( ) ; /**
           * Execute the INSERT (this may throw an exception)
           */ $ primaryKey = $ table :: insert ( $ data ) ; /**
           * Normalize the result to an array indexed by primary key column(s)
           */ $ tempPrimaryKey = $ table -> getPrimaryKey ( ) ; $ newPrimaryKey = [ current ( $ tempPrimaryKey ) => $ primaryKey ] ; /**
           * Save the new primary key value in object. The primary key may have
           * been generated by a sequence or auto-increment mechanism, and this
           * merge should be done before the afterInsert() method is run, so the
           * new values are available for logging, etc.
           */ $ this -> setFromArray ( $ newPrimaryKey ) ; /**
           * Run post-INSERT logic
           */ $ this -> afterInsert ( ) ; /**
           * Update the "clean" to reflect that the data has been inserted.
           */ $ this -> clean = $ this -> toArray ( ) ; return $ newPrimaryKey ; }
docstring: Insert row to Db
  
  @return mixed The primary key value(s), as an associative array if the
  key is compound, or a scalar if the key is single-column
  @throws InvalidPrimaryKeyException
  @throws TableNotFoundException
docstring_tokens: Insert row to Db