Advertisement
nathan30

Untitled

Mar 13th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. public static function index($request,$context){
  2.         context::setSessionAttribute("nb_tweet_init", tweetTable::countTweet());
  3.         $context->title = "Index";
  4.         if(context::getSessionAttribute("connect") != "true"){
  5.             context::redirect("goater.php?action=login");
  6.         }
  7.  
  8.         $bdd = new PDO('pgsql:host=localhost dbname=etd user=uapv1402577 password=jenYv1'); // Utilisation de cette connexion au lieu de dbconnection() pour l'utilisation du fetchColumn();
  9.         $id = context::getSessionAttribute("id");
  10.         $user = utilisateurTable::getUserById($id)[0];
  11.         context::setSessionAttribute("id",$user->id);
  12.         context::setSessionAttribute("nom",$user->nom);
  13.         context::setSessionAttribute("prenom",$user->prenom);
  14.         context::setSessionAttribute("identifiant",$user->identifiant);
  15.         context::setSessionAttribute("statut",$user->statut);
  16.         context::setSessionAttribute("avatar",$user->avatar);
  17.         context::setSessionAttribute("nb_tweet",$bdd -> query("SELECT COUNT (*) from jabaianb.tweet where emetteur=$user->id")->fetchColumn());
  18.  
  19.         if(isset($request["tweet"])){
  20.             tweetTable::sendTweet($request["tweet"]);
  21.         }
  22.  
  23.         return context::SUCCESS;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement