/**
  * Delete a comment.
  *
  * @param integer $iRecipientId The Comment Recipient ID.
  * @param string $sTable The Comment Table.
  * @return boolean Returns TRUE on success, FALSE on failure.
  */
 public static function deleteRecipient($iRecipientId, $sTable)
 {
     $sTable = CommentCore::checkTable($sTable);
     $iRecipientId = (int) $iRecipientId;
     $rStmt = Db::getInstance()->prepare('DELETE FROM' . Db::prefix('Comments' . $sTable) . 'WHERE recipient = :recipient');
     $rStmt->bindValue(':recipient', $iRecipientId, \PDO::PARAM_INT);
     return $rStmt->execute();
 }
Beispiel #2
0
 /**
  * To prevent spam!
  *
  * @param integer $iSenderId
  * @param integer $iWaitTime In minutes!
  * @param string $sCurrentTime In date format: 0000-00-00 00:00:00
  * @param string $sTable
  * @return boolean Return TRUE if the weather was fine, otherwise FALSE
  */
 public function checkWaitSend($iSenderId, $iWaitTime, $sCurrentTime, $sTable)
 {
     $sTable = CommentCore::checkTable($sTable);
     $rStmt = Db::getInstance()->prepare('SELECT commentId FROM' . Db::prefix('Comments' . $sTable) . 'WHERE sender = :sender AND DATE_ADD(createdDate, INTERVAL :waitTime MINUTE) > :currentTime LIMIT 1');
     $rStmt->bindValue(':sender', $iSenderId, \PDO::PARAM_INT);
     $rStmt->bindValue(':waitTime', $iWaitTime, \PDO::PARAM_INT);
     $rStmt->bindValue(':currentTime', $sCurrentTime, \PDO::PARAM_STR);
     $rStmt->execute();
     return $rStmt->rowCount() === 0;
 }
 protected function totalComments($sTable, $iDay = 0)
 {
     CommentCore::checkTable($sTable);
     $iDay = (int) $iDay;
     $sSqlDay = $iDay > 0 ? ' WHERE (createdDate + INTERVAL ' . $iDay . ' DAY) > NOW()' : '';
     $rStmt = Db::getInstance()->prepare('SELECT COUNT(commentId) AS totalComments FROM' . Db::prefix('Comments' . $sTable) . $sSqlDay);
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     return (int) $oRow->totalComments;
 }