I hope there are some PHP developer's in this list, i'm trying to
override the save method in a model, my model class goes like this:
class Interest
include DataMapper::Resource
# properties
property :user_id, Integer, :key => true
property :question_id, Integer, :key => true
timestamps :at
# associations
belongs_to :user, :child_key => [:user_id]
belongs_to :question, :child_key => [:question_id]
end
And here is the PHP code that i'm translating to DataMapper
$con = Propel::getConnection();
try
{
$con->begin();
$ret = parent::save($con);
// update interested_users in question table
$question = $this->getQuestion();
$interested_users = $question->getInterestedUsers();
$question->setInterestedUsers($interested_users + 1);
$question->save($con);
$con->commit();
return $ret;
}
catch (Exception $e)
{
$con->rollback();
throw $e;
}
I tried with this:
def save
transaction do |txn|
question.interested_users += 1
end
end
The question model already have the property 'interested_users'.
Thanks in advance.
--
Rafael George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---