Created
June 23, 2010 16:04
-
-
Save KendallHopkins/450131 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function save(PropelPDO $con = null) | |
{ | |
if ($this->isDeleted()) { | |
throw new PropelException("You cannot save an object that has been deleted."); | |
} | |
if ($con === null) { | |
$con = Propel::getConnection(SF_model_forum_postPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); | |
} | |
$con->beginTransaction(); | |
$isInsert = $this->isNew(); | |
try { | |
$ret = $this->preSave($con); | |
if ($isInsert) { | |
$ret = $ret && $this->preInsert($con); | |
// timestampable behavior | |
if (!$this->isColumnModified(forum_postPeer::CREATED_AT)) { | |
$this->setCreatedAt(time()); | |
} | |
if (!$this->isColumnModified(forum_postPeer::UPDATED_AT)) { | |
$this->setUpdatedAt(time()); | |
} | |
} else { | |
$ret = $ret && $this->preUpdate($con); | |
// timestampable behavior | |
if ($this->isModified() && !$this->isColumnModified(forum_postPeer::UPDATED_AT)) { | |
$this->setUpdatedAt(time()); | |
} | |
} | |
if ($ret) { | |
$affectedRows = $this->doSave($con); | |
if ($isInsert) { | |
$this->postInsert($con); | |
} else { | |
$this->postUpdate($con); | |
} | |
$this->postSave($con); | |
SF_model_forum_postPeer::addInstanceToPool($this); | |
} else { | |
$affectedRows = 0; | |
} | |
$con->commit(); | |
return $affectedRows; | |
} catch (PropelException $e) { | |
$con->rollBack(); | |
throw $e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment