final public function save()
    {
        $this->checkReadOnly();

        /*
         * Allows pre-save logic to be applied to any row.
         *
         * Zend_Db_Table_Row only uses to do it on _insert OR _update,
         * here we can use the very same rules to be applied in both methods.
         */
        $this->_save();

        if (count($this->_errors)) {
            throw new Zend_Db_Table_Row_Exception('This row contain errors.');
        }

        foreach ($this->_data as $column => &$value) {
            if ($value instanceof DateTime) {
                // Should replace with Benri_Util_DateTime.
                if (!($value instanceof Benri_Util_DateTime)) {
                    $value = new Benri_Util_DateTime($value->format('U'));
                }

                $value->setFormat('Y-m-d H:i:s');
            }
        }

        if ($this->isNewRecord()) {
            if ($this->offsetExists('created_at')) {
                $this->created_at = new Benri_Util_DateTime();
                $this->created_at->setFormat('Y-m-d H:i:s');
            }
        }

        if ($this->offsetExists('updated_at')) {
            $this->updated_at = new Benri_Util_DateTime();
            $this->updated_at->setFormat('Y-m-d H:i:s');
        }

        /// Saves the properties to the database
        parent::save();

        /// Run post-SAVE logic
        $this->_postSave();

        /// chain
        return $this;
    }
final public function save()
    {
        $this->checkReadOnly();

        /*
         * Allows pre-save logic to be applied to any row.
         *
         * Zend_Db_Table_Row only uses to do it on _insert OR _update,
         * here we can use the very same rules to be applied in both methods.
         */
        $this->_save();

        if (count($this->_errors)) {
            throw new Zend_Db_Table_Row_Exception('This row contain errors.');
        }

        foreach ($this->_data as $column => &$value) {
            if ($value instanceof DateTime) {
                // Should replace with Benri_Util_DateTime.
                if (!($value instanceof Benri_Util_DateTime)) {
                    $value = new Benri_Util_DateTime($value->format('U'));
                }

                $value->setFormat('Y-m-d H:i:s');
            }
        }

        if ($this->isNewRecord()) {
            if ($this->offsetExists('created_at')) {
                $this->created_at = new Benri_Util_DateTime();
                $this->created_at->setFormat('Y-m-d H:i:s');
            }
        }

        if ($this->offsetExists('updated_at')) {
            $this->updated_at = new Benri_Util_DateTime();
            $this->updated_at->setFormat('Y-m-d H:i:s');
        }

        /// Saves the properties to the database
        parent::save();

        /// Run post-SAVE logic
        $this->_postSave();

        /// chain
        return $this;
    }
final public function save ( ) { $ this -> checkReadOnly ( ) ; /*
         * Allows pre-save logic to be applied to any row.
         *
         * Zend_Db_Table_Row only uses to do it on _insert OR _update,
         * here we can use the very same rules to be applied in both methods.
         */ $ this -> _save ( ) ; if ( count ( $ this -> _errors ) ) { throw new Zend_Db_Table_Row_Exception ( 'This row contain errors.' ) ; } foreach ( $ this -> _data as $ column => & $ value ) { if ( $ value instanceof DateTime ) { // Should replace with Benri_Util_DateTime. if ( ! ( $ value instanceof Benri_Util_DateTime ) ) { $ value = new Benri_Util_DateTime ( $ value -> format ( 'U' ) ) ; } $ value -> setFormat ( 'Y-m-d H:i:s' ) ; } } if ( $ this -> isNewRecord ( ) ) { if ( $ this -> offsetExists ( 'created_at' ) ) { $ this -> created_at = new Benri_Util_DateTime ( ) ; $ this -> created_at -> setFormat ( 'Y-m-d H:i:s' ) ; } } if ( $ this -> offsetExists ( 'updated_at' ) ) { $ this -> updated_at = new Benri_Util_DateTime ( ) ; $ this -> updated_at -> setFormat ( 'Y-m-d H:i:s' ) ; } /// Saves the properties to the database parent :: save ( ) ; /// Run post-SAVE logic $ this -> _postSave ( ) ; /// chain return $ this ; }
Saves the properties to the database.

This performs an intelligent insert/update, and reloads the properties
with fresh data from the table on success.

@return mixed The primary key value(s), as an associative array if the
key is compound, or a scalar if the key is single-column
Saves the properties to the database .