src/db/orm/PersistableObject.php
private function insert() {
        if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this);

        // pre-processing hook
        if ($this->beforeInsert() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();

        // collect column values
        $values = [];
        foreach ($mapping['columns'] as $column => $property) {
            $values[$column] = $this->getPhysicalValue($column);
        };

        // perform insertion
        $id = $this->doInsert($values);
        $this->_modified = false;

        // assign the returned identity value
        $idName = $mapping['identity']['name'];
        if ($this->$idName === null)
            $this->$idName = $id;

        // post-processing hook
        $this->afterInsert();
        return $this;
    }
private function insert() {
        if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this);

        // pre-processing hook
        if ($this->beforeInsert() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();

        // collect column values
        $values = [];
        foreach ($mapping['columns'] as $column => $property) {
            $values[$column] = $this->getPhysicalValue($column);
        };

        // perform insertion
        $id = $this->doInsert($values);
        $this->_modified = false;

        // assign the returned identity value
        $idName = $mapping['identity']['name'];
        if ($this->$idName === null)
            $this->$idName = $id;

        // post-processing hook
        $this->afterInsert();
        return $this;
    }
private function insert ( ) { if ( $ this -> isPersistent ( ) ) throw new RuntimeException ( 'Cannot insert already persistent ' . $ this ) ; // pre-processing hook if ( $ this -> beforeInsert ( ) !== true ) return $ this ; $ mapping = $ this -> dao ( ) -> getMapping ( ) ; // collect column values $ values = [ ] ; foreach ( $ mapping [ 'columns' ] as $ column => $ property ) { $ values [ $ column ] = $ this -> getPhysicalValue ( $ column ) ; } ; // perform insertion $ id = $ this -> doInsert ( $ values ) ; $ this -> _modified = false ; // assign the returned identity value $ idName = $ mapping [ 'identity' ] [ 'name' ] ; if ( $ this -> $ idName === null ) $ this -> $ idName = $ id ; // post-processing hook $ this -> afterInsert ( ) ; return $ this ; }
Insert this instance into the storage mechanism.

@return $this
Insert this instance into the storage mechanism .