public function saveAsNew($validate = true)
    {
        if ($validate && (!$this->validate())) {
            return false;
        }
        if (!is_string($this->_pk)) {
            $this->error("Can't duplicate rows in tables with multiple primary keys!");
            return false;
        }
        $originalBackup = $this->_originalPk;
        unset($this->_attributes[$this->_pk]);
        $this->_originalPk = $this->_db->table($this->_tableName)->insert($this->_attributes);
        if (!$this->_originalPk) {
            $this->_originalPk = $originalBackup;
            return false; // error when trying to insert;
        }
        $this->reload();
        return $this->_db->lastInsertId();
    }
public function saveAsNew($validate = true)
    {
        if ($validate && (!$this->validate())) {
            return false;
        }
        if (!is_string($this->_pk)) {
            $this->error("Can't duplicate rows in tables with multiple primary keys!");
            return false;
        }
        $originalBackup = $this->_originalPk;
        unset($this->_attributes[$this->_pk]);
        $this->_originalPk = $this->_db->table($this->_tableName)->insert($this->_attributes);
        if (!$this->_originalPk) {
            $this->_originalPk = $originalBackup;
            return false; // error when trying to insert;
        }
        $this->reload();
        return $this->_db->lastInsertId();
    }
public function saveAsNew ( $ validate = true ) { if ( $ validate && ( ! $ this -> validate ( ) ) ) { return false ; } if ( ! is_string ( $ this -> _pk ) ) { $ this -> error ( "Can't duplicate rows in tables with multiple primary keys!" ) ; return false ; } $ originalBackup = $ this -> _originalPk ; unset ( $ this -> _attributes [ $ this -> _pk ] ) ; $ this -> _originalPk = $ this -> _db -> table ( $ this -> _tableName ) -> insert ( $ this -> _attributes ) ; if ( ! $ this -> _originalPk ) { $ this -> _originalPk = $ originalBackup ; return false ; // error when trying to insert; } $ this -> reload ( ) ; return $ this -> _db -> lastInsertId ( ) ; }
It will create a copy of the current element in DB. This Object will be the new copy just inserted.
@param bool $validate
@return bool|int
It will create a copy of the current element in DB . This Object will be the new copy just inserted .