src/Database/Model.php
public function save()
    {
        // Validate
        if (!$this->validates()) {
            return false;
        }

        // Run filter
        $this->runFilters('before', $this->_isNew ? 'create' : 'save');

        // Get data
        $data = static::data();

        // Create
        if ($this->_isNew) {
            $result = static::connection()
                ->insert($data)
                ->into(static::table())
                ->exec();

            $this->id = static::connection()->lastInsertId();
        }
        // Update
        else {
            $result = static::connection()
                ->update(static::table())
                ->set($data)
                ->where(static::$_primaryKey . ' = ?', $data[static::$_primaryKey])
                ->exec();
        }

        // Run filters
        $this->runFilters('after', $this->_isNew ? 'create' : 'save');

        return $result;
    }
public function save()
    {
        // Validate
        if (!$this->validates()) {
            return false;
        }

        // Run filter
        $this->runFilters('before', $this->_isNew ? 'create' : 'save');

        // Get data
        $data = static::data();

        // Create
        if ($this->_isNew) {
            $result = static::connection()
                ->insert($data)
                ->into(static::table())
                ->exec();

            $this->id = static::connection()->lastInsertId();
        }
        // Update
        else {
            $result = static::connection()
                ->update(static::table())
                ->set($data)
                ->where(static::$_primaryKey . ' = ?', $data[static::$_primaryKey])
                ->exec();
        }

        // Run filters
        $this->runFilters('after', $this->_isNew ? 'create' : 'save');

        return $result;
    }
public function save ( ) { // Validate if ( ! $ this -> validates ( ) ) { return false ; } // Run filter $ this -> runFilters ( 'before' , $ this -> _isNew ? 'create' : 'save' ) ; // Get data $ data = static :: data ( ) ; // Create if ( $ this -> _isNew ) { $ result = static :: connection ( ) -> insert ( $ data ) -> into ( static :: table ( ) ) -> exec ( ) ; $ this -> id = static :: connection ( ) -> lastInsertId ( ) ; } // Update else { $ result = static :: connection ( ) -> update ( static :: table ( ) ) -> set ( $ data ) -> where ( static :: $ _primaryKey . ' = ?' , $ data [ static :: $ _primaryKey ] ) -> exec ( ) ; } // Run filters $ this -> runFilters ( 'after' , $ this -> _isNew ? 'create' : 'save' ) ; return $ result ; }
Saves the model to the database.

@return boolean
Saves the model to the database .