Beispiel #1
0
 /**
  * Constructor.
  * @param Post $post Instancia con los datos sin modificar.
  * @param string $postTitle Titulo.
  * @param string $postContents Contenido.
  * @param int $commentStatus Estado de los comentarios.
  * @param int $postStatus Estado.
  */
 public function __construct(Post $post, $postTitle, $postContents, $commentStatus, $postStatus)
 {
     parent::__construct(Post::getTableName());
     $this->post = $post;
     $this->postTitle = $postTitle;
     $this->postContents = $postContents;
     $this->commentStatus = $commentStatus;
     $this->postStatus = $postStatus;
 }
Beispiel #2
0
 /**
  * Constructor.
  * @param string $postTitle Titulo.
  * @param string $postContents Contenido.
  * @param int $commentStatus Estado de los comentarios.
  * @param int $postStatus Estado.
  * @param int $userID Identificador del autor.
  */
 public function __construct($postTitle, $postContents, $commentStatus, $postStatus, $userID)
 {
     parent::__construct(Post::getTableName(), self::$COLUMNS, self::$VALUES);
     $this->postTitle = $postTitle;
     $this->postContents = $postContents;
     $this->commentStatus = $commentStatus;
     $this->postStatus = $postStatus;
     $this->userID = $userID;
 }
Beispiel #3
0
 /**
  * Metodo que obtiene todos los posts segun su fecha de actualización.
  * @param string $value Fecha.
  * @return Posts|bool Si es FALSE, no hay datos.
  */
 public static function selectByUpdate($value)
 {
     $select = self::selectBy(Post::getTableName(), $value, Post::POST_UPDATE);
     return self::getInstanceData($select);
 }
Beispiel #4
0
 /**
  * Metodo que obtiene el número de POST realializados.
  * @return int
  */
 public function getCountPosts()
 {
     $db = DBController::getConnection();
     $table = Post::getTableName();
     $fetch = 'fetchAll';
     $userIDPost = Post::USER_ID;
     $where = "{$userIDPost} = :{$userIDPost}";
     $prepare = [DBController::prepareStatement(":{$userIDPost}", $this->getID(), \PDO::PARAM_INT)];
     $columns = 'COUNT(*) AS count';
     $select = $db->select($table, $fetch, $where, $prepare, $columns);
     return $select[0]['count'];
 }
Beispiel #5
0
 /**
  * Constructor.
  * @param int $id Identificador.
  */
 public function __construct($id)
 {
     parent::__construct($id, Post::getTableName());
 }