Skip to content

Instantly share code, notes, and snippets.

@ternel
Created January 6, 2011 15:54
Show Gist options
  • Save ternel/768060 to your computer and use it in GitHub Desktop.
Save ternel/768060 to your computer and use it in GitHub Desktop.
<?php
class Answer extends BaseAnswer
{
public function preSave($obj)
{
if ($this->getIsTrue())
{
$q = Doctrine_Query::create()
->update('Answer')
->set('is_true', '0')
->where('question_id = ?', $this->getQuestionId());
$q->execute();
}
}
}
@damienalexandre
Copy link

public function preSave($obj)
{
if ($this->getIsTrue())
{
$q = Doctrine_Query::create()
->update('Answer')
->set('is_true', '0')
->where('question_id = ?', $this->getQuestionId())
->andWhere('id != ?, $this->getId());

        $q->execute();
    }
}

@ternel
Copy link
Author

ternel commented Jan 6, 2011

getModified(); if ($this->getIsTrue() && isset($modified['is_true']) && $modified['is_true']) { $q = Doctrine_Query::create() ->update('Answer') ->set('is_true', '0') ->where('question_id = ?', $this->getQuestionId()); ``` $q->execute(); } } ``` }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment