Example #1
0
 /**
  * Metodo llamado por la función UPDATE.
  * @param int $id
  * @return array
  */
 protected function dataUpdate($id)
 {
     global $urlSite;
     $comment = Comment::selectByID($id);
     //En caso de que no exista.
     if (empty($comment)) {
         Messages::addError('Error. El commentario no existe.');
         header("Location: {$urlSite}" . 'admin/comment');
         exit;
     }
     if (filter_input(\INPUT_POST, 'update')) {
         $dataInput = $this->getDataInput();
         $update = new CommentUpdate($comment, $dataInput['commentAutor'], $dataInput['commentAuthorEmail'], $dataInput['commentStatus'], $dataInput['commentContents']);
         //Si ocurre un error la función "$update->update()" retorna FALSE.
         if ($update->update()) {
             Messages::addSuccess('Comentario actualizado correctamente.');
             $comment = $update->getDataUpdate();
         } else {
             Messages::addError('Error al actualizar el comentario.');
         }
     }
     return ['comment' => $comment, 'actionUpdate' => \TRUE];
 }
Example #2
0
 /**
  * Metodo que obtiene todos los comentarios segun el identificador del post.
  * @param int $value
  * @return Comments
  */
 public static function selectByPostID($value)
 {
     $select = self::selectBy(Comment::getTableName(), $value, Comment::POST_ID, \PDO::PARAM_INT);
     return self::getInstanceData($select);
 }
Example #3
0
 /**
  * Metodo que obtiene el objeto con los datos actualizados.
  * @return Comment
  */
 public function getDataUpdate()
 {
     //Obtiene el primer dato el cual corresponde al id.
     $id = $this->prepareStatement[0]['value'];
     return Comment::selectByID($id);
 }
Example #4
0
 /**
  * Constructor.
  * @param int $id Identificador.
  */
 public function __construct($id)
 {
     parent::__construct($id, Comment::getTableName());
 }