Example #1
0
 /**
  * @param Vote $vote
  */
 public function add($vote)
 {
     $values = $vote->toArray();
     $values['tstamp'] = time();
     $values['crdate'] = time();
     $this->getDatabaseConnection()->exec_INSERTquery($this->tableName, $values);
     $vote->_setProperty('uid', $this->getDatabaseConnection()->sql_insert_id());
     // Establish relation between $vote and the voted object.
     $relation['uid_local'] = $vote->getUid();
     $relation['uid_foreign'] = $vote->getVotedObject()->getIdentifier();
     $relation['tablenames'] = $vote->getVotedObject()->getContentType();
     $relation['fieldname'] = $vote->getVotedObject()->getRelationalFieldName();
     $this->getDatabaseConnection()->exec_INSERTquery('tx_votable_vote_record_mm', $relation);
     // Post process data
     $this->keepCleanRelationalTable();
     $this->cacheNumberOfVotes($vote);
     $this->cacheRank($vote);
 }