コード例 #1
0
ファイル: M_tweets.php プロジェクト: Skizz1/Tweet_academie
     * @param int $id ID
     */
    public function remove($id)
    {
        $sql = "DELETE FROM {$this->table} WHERE id = {$id}";
        $req = Database::get()->prepare($sql);
        $req->execute();
    }
    /**
     * Compte le nombre de tweets d'un utilisateur
     * @param int $id ID
     * @return nombre de tweets
     */
    public function tweetCount($id)
    {
        $sql = "SELECT COUNT(id) AS tweets FROM {$this->table} WHERE user_id = {$id}";
        $req = Database::get()->prepare($sql);
        $req->execute();
        return $req;
    }
    public function readTweet($id)
    {
        $connexion = \App\Model\Database::get()->prepare("SELECT * from tp_follow  INNER JOIN tp_users on tp_users.id = tp_follow.follow_id INNER JOIN tp_tweets on  tp_users.id  =  tp_tweets.user_id  WHERE follower_id = '" . $id . "' OR follow_id = '" . $id . "' GROUP BY tp_tweets.id");
        $connexion->execute();
        $data = $connexion->fetchAll();
        return $data;
    }
}
$tweets = new TweetsModel();
$tweetCount = $tweets->tweetCount($tweets->userId);