/**
  * Пересчитывает счетчики голосований
  *
  * @return bool
  */
 public function RecalculateVote()
 {
     $sql = "\n                UPDATE " . Config::Get('db.table.lsgallery.image') . " i\n                SET i.image_count_vote_up = (\n                    SELECT count(*)\n                    FROM " . Config::Get('db.table.vote') . " v\n                    WHERE\n                        v.target_id = i.image_id\n                    AND\n                        v.vote_direction = 1\n                    AND\n                        v.target_type = 'image'\n                ), i.image_count_vote_down = (\n                    SELECT count(*)\n                    FROM " . Config::Get('db.table.vote') . " v\n                    WHERE\n                        v.target_id = i.image_id\n                    AND\n                        v.vote_direction = -1\n                    AND\n                        v.target_type = 'image'\n                ), i.image_count_vote_abstain = (\n                    SELECT count(*)\n                    FROM " . Config::Get('db.table.vote') . " v\n                    WHERE\n                        v.target_id = i.image_id\n                    AND\n                        v.vote_direction = 0\n                    AND\n                        v.target_type = 'image'\n                ), i.image_count_vote = (\n                    SELECT count(*)\n                    FROM " . Config::Get('db.table.vote') . " v\n                    WHERE\n                        v.target_id = i.image_id\n                    AND\n                        v.target_type = 'image'\n                )\n            ";
     if ($this->oDb->query($sql)) {
         return true;
     }
     return false;
 }
 /**
  * Удаляет запись из БД и Store
  * @return $this
  */
 public final function delete()
 {
     $this->_preDelete();
     $query = Lms_Item_Sql::deleteStatement($this->getTableName(), $this->_getAssocPkValue());
     $this->_masterDb->query($query);
     Lms_Item_Store::delete($this->getTableName(), $this->_scalarPkValue);
     $this->_postDelete();
     return $this;
 }