original_string: public function insert()
      {
          if ($this->stored) {
              throw new \LogicException("You may not insert an already stored entity");
          }
  
          $this->callEvent('insert');
  
          if (empty($this->modified)) {
              return;
          }
  
          $values = array_intersect_key($this->values, $this->modified);
          $this->connection->insert(static::$table, $values, static::$types);
          //this will only work with some database vendors for now.
          $this->values[static::$primary_key] = $this->connection->lastInsertId();
          $this->setStored();
      }
code: public function insert()
      {
          if ($this->stored) {
              throw new \LogicException("You may not insert an already stored entity");
          }
  
          $this->callEvent('insert');
  
          if (empty($this->modified)) {
              return;
          }
  
          $values = array_intersect_key($this->values, $this->modified);
          $this->connection->insert(static::$table, $values, static::$types);
          //this will only work with some database vendors for now.
          $this->values[static::$primary_key] = $this->connection->lastInsertId();
          $this->setStored();
      }
code_tokens: public function insert ( ) { if ( $ this -> stored ) { throw new \ LogicException ( "You may not insert an already stored entity" ) ; } $ this -> callEvent ( 'insert' ) ; if ( empty ( $ this -> modified ) ) { return ; } $ values = array_intersect_key ( $ this -> values , $ this -> modified ) ; $ this -> connection -> insert ( static :: $ table , $ values , static :: $ types ) ; //this will only work with some database vendors for now. $ this -> values [ static :: $ primary_key ] = $ this -> connection -> lastInsertId ( ) ; $ this -> setStored ( ) ; }
docstring: Persist this entity to the database using an insert query.
docstring_tokens: Persist this entity to the database using an insert query .