src/Synapse/Mapper/InserterTrait.php
protected function insertRow(AbstractEntity $entity)
    {
        $values  = $entity->getDbValues();
        $columns = array_keys($values);

        if ($this->autoIncrementColumn && ! array_key_exists($this->autoIncrementColumn, $values)) {
            throw new LogicException('auto_increment column ' . $this->autoIncrementColumn . ' not found');
        }

        $query = $this->getSqlObject()
            ->insert()
            ->columns($columns)
            ->values($values);

        $statement = $this->getSqlObject()->prepareStatementForSqlObject($query);
        $result    = $statement->execute();

        if ($this->autoIncrementColumn && ! $values[$this->autoIncrementColumn]) {
            $entity->exchangeArray([
                $this->autoIncrementColumn => $result->getGeneratedValue()
            ]);
        }
    }
protected function insertRow(AbstractEntity $entity)
    {
        $values  = $entity->getDbValues();
        $columns = array_keys($values);

        if ($this->autoIncrementColumn && ! array_key_exists($this->autoIncrementColumn, $values)) {
            throw new LogicException('auto_increment column ' . $this->autoIncrementColumn . ' not found');
        }

        $query = $this->getSqlObject()
            ->insert()
            ->columns($columns)
            ->values($values);

        $statement = $this->getSqlObject()->prepareStatementForSqlObject($query);
        $result    = $statement->execute();

        if ($this->autoIncrementColumn && ! $values[$this->autoIncrementColumn]) {
            $entity->exchangeArray([
                $this->autoIncrementColumn => $result->getGeneratedValue()
            ]);
        }
    }
protected function insertRow ( AbstractEntity $ entity ) { $ values = $ entity -> getDbValues ( ) ; $ columns = array_keys ( $ values ) ; if ( $ this -> autoIncrementColumn && ! array_key_exists ( $ this -> autoIncrementColumn , $ values ) ) { throw new LogicException ( 'auto_increment column ' . $ this -> autoIncrementColumn . ' not found' ) ; } $ query = $ this -> getSqlObject ( ) -> insert ( ) -> columns ( $ columns ) -> values ( $ values ) ; $ statement = $ this -> getSqlObject ( ) -> prepareStatementForSqlObject ( $ query ) ; $ result = $ statement -> execute ( ) ; if ( $ this -> autoIncrementColumn && ! $ values [ $ this -> autoIncrementColumn ] ) { $ entity -> exchangeArray ( [ $ this -> autoIncrementColumn => $ result -> getGeneratedValue ( ) ] ) ; } }
Insert an entity's DB row using the given values.
Set the ID on the entity from the query result.

@param  AbstractEntity $entity
Insert an entity s DB row using the given values . Set the ID on the entity from the query result .