public function save()
    {
        $query = new QueryBuilder(self::$_connection);

        if($this->_isInsert) {
            $query->insert($this->getTable())
                  ->values($this->_changed);

            $id = self::$_connection->insert($query->getQuery());
            $this->_data[$this->_primaryKey] = $id;

            $this->_isInsert = false;
            $this->_changed  = [];

            return;
        }

        $query->update($this->getTable())
              ->set($this->_changed)
              ->where([
                  $this->_primaryKey => $this->_data[$this->_primaryKey]
              ])
              ->execute();

        $this->_changed = [];
    }
public function save()
    {
        $query = new QueryBuilder(self::$_connection);

        if($this->_isInsert) {
            $query->insert($this->getTable())
                  ->values($this->_changed);

            $id = self::$_connection->insert($query->getQuery());
            $this->_data[$this->_primaryKey] = $id;

            $this->_isInsert = false;
            $this->_changed  = [];

            return;
        }

        $query->update($this->getTable())
              ->set($this->_changed)
              ->where([
                  $this->_primaryKey => $this->_data[$this->_primaryKey]
              ])
              ->execute();

        $this->_changed = [];
    }
public function save ( ) { $ query = new QueryBuilder ( self :: $ _connection ) ; if ( $ this -> _isInsert ) { $ query -> insert ( $ this -> getTable ( ) ) -> values ( $ this -> _changed ) ; $ id = self :: $ _connection -> insert ( $ query -> getQuery ( ) ) ; $ this -> _data [ $ this -> _primaryKey ] = $ id ; $ this -> _isInsert = false ; $ this -> _changed = [ ] ; return ; } $ query -> update ( $ this -> getTable ( ) ) -> set ( $ this -> _changed ) -> where ( [ $ this -> _primaryKey => $ this -> _data [ $ this -> _primaryKey ] ] ) -> execute ( ) ; $ this -> _changed = [ ] ; }
Saves the changes to the database.
Saves the changes to the database .