Skip to content

Instantly share code, notes, and snippets.

@KendallHopkins
Created June 23, 2010 16:04
Show Gist options
  • Save KendallHopkins/450131 to your computer and use it in GitHub Desktop.
Save KendallHopkins/450131 to your computer and use it in GitHub Desktop.
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