/** * Saves the counter into the database. * * @param BaseObject $object */ public function saveCounter(BaseObject $object) { if (isset($object->_counter) && isset($object->_forced) && $object->_forced) { $c = new Criteria(); $c->add(sfCounterPeer::COUNTABLE_ID, $object->getPrimaryKey()); $c->add(sfCounterPeer::COUNTABLE_MODEL, get_class($object)); $counter = sfCounterPeer::doSelectOne($c); if (is_null($counter)) { $counter = $object->_counter; } else { $counter->setCounter($object->_counter->getCounter()); } $object->_counter = $counter; $object->_forced = false; } $object->_counter->save(); }