本文整理汇总了PHP中Tweet::LoadTweetById方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::LoadTweetById方法的具体用法?PHP Tweet::LoadTweetById怎么用?PHP Tweet::LoadTweetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::LoadTweetById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
header("Location: login.php");
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
$tweetToShow = Tweet::LoadTweetById($id);
$userId = (int) $tweetToShow->getUserId();
$user = User::GetUserById($userId);
echo "<h1> {$user->getName()}</h1>";
echo $tweetToShow->getTweetText() . "<br>";
echo $tweetToShow->getTweetDate() . "<br />";
$coms = count($tweetToShow->getAllComments());
if ($_SESSION['userId'] == $userId) {
echo "<a href='editTweet.php?id={$id}'> Edytuj</a>";
echo "<a href='removeTweet.php?id={$id}'> Usuń</a>";
}
echo "<br>Liczba komentarzy: {$coms} ";
echo "<hr />";
echo "\n<form method='post'>\n <label>\n <input type='text' name='comment' placeholder='wpisz swój komentarz'>\n </label>\n <input type='submit'>\n</form>\n";
foreach ($tweetToShow->getAllComments() as $comment) {
$idOfCommentingUser = $comment->getUserId();
$commentingUser = User::GetUserById($idOfCommentingUser);
echo "<h3>{$commentingUser->getName()}</h3>";
echo $comment->getCommentText() . "<br>";
echo $comment->getCommentDate() . "<br>";
echo "<hr />";
}
示例2: header
<?php
require_once "./src/conection.php";
if (isset($_SESSION['userId']) !== TRUE) {
header("Location: login.php");
}
$id = $_GET['id'];
$tweetToEdit = Tweet::LoadTweetById($id);
if ($_SESSION['userId'] == $tweetToEdit->getUserId()) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tweetToEdit->updateTweet($_POST['tweet_text']);
header("Location: showUser.php?userId=" . $_SESSION['userId']);
}
echo "\n <form method='POST'>\n <p>\n <textarea name='tweet_text' cols='40' rows='4'>{$tweetToEdit->getTweetText()}</textarea>\n </p>\n <input type='submit' value='Edytuj'>\n </form>";
}
示例3: header
<?php
require_once "./src/conection.php";
if (isset($_SESSION['userId']) !== TRUE) {
header("Location: login.php");
}
$id = $_GET['id'];
$tweetToRemove = Tweet::LoadTweetById($id);
$userId = User::GetUserById($id);
if ($_SESSION['userId'] == $tweetToRemove->getUserId()) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tweetToRemove->removeTweet();
header("Location: showUser.php?userId=" . $userId->getId());
}
echo "\n <form method='POST'>\n <p>\n Napewno chcesz usunac tweeta?\n </p>\n <input type='submit' value='Usun'>\n </form>";
} else {
echo "Nie da rady";
}