strange doctrine update problem
Posted
by larryzhao
on Stack Overflow
See other posts from Stack Overflow
or by larryzhao
Published on 2010-06-05T09:10:02Z
Indexed on
2010/06/05
9:12 UTC
Read the original article
Hit count: 157
Hi, guys,
I have a simple table like following:
class SnookerCurrentInfo extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('current_frame_id', 'integer', 4, array('notnull' => 'false'));
$this->hasColumn('current_player_id', 'integer', 4, array('notnull' => 'false'));
$this->hasColumn('current_score1', 'integer', 4, array('notnull' => 'false'));
$this->hasColumn('current_score2', 'integer', 4, array('notnull' => 'false'));
}
public function setUp(){
$this->setTableName('snooker_current_info');
}
}
and I would like to keep only one entry in this table. So every time the value is changed I read the entry with id = 1 out and change the object and execute save. like the following:
$info = Doctrine::getTable('SnookerCurrentInfo')->find(1);
$info->current_frame_id = $jsonInfo['current_frame_id'];
$info->current_player_id = $jsonInfo['current_player_id'];
$info->current_score1 = $jsonInfo['current_score1'];
$info->current_score2 = $jsonInfo['current_score2'];
$info->save();
but the strange thing is, I try to make it clear. Let's say at first, the entry is (30, 1, 1, 0) and I switch player, so update the entry to (30, 2, 1, 0). and I switch the player back again, so the entry should be updated to (30, 1, 1, 0), but this is not affected to the database!! In the database, the entry still remains as (30, 2, 1, 0)!!!!
But if after (30, 2, 1, 0), I update the score to (30, 2, 1, 1) and then switch the player back (30, 1, 1, 1) then this is ok.
What's that? How should I deal with it?
Thanks for a lot helping, really urgent!!
© Stack Overflow or respective owner