本文整理汇总了PHP中Tweet::getTweetById方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::getTweetById方法的具体用法?PHP Tweet::getTweetById怎么用?PHP Tweet::getTweetById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::getTweetById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_start
<?php
require_once "src/connection.php";
session_start();
if (isset($_SESSION['user']) == false) {
header("location: login.php");
}
$myUser = $_SESSION['user'];
if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_GET['tweetId'])) {
$tweetIdToShow = $_GET['tweetId'];
$tweetToShow = Tweet::getTweetById($tweetIdToShow);
}
if ($tweetToShow == true) {
echo "Tweet: <b>{$tweetToShow->getText()}</b>";
echo "<p>{$tweetToShow->getCreationDate()}</p><br><br>";
} else {
echo "Taki tweet nie istnieje, spieprzaj dziadu.<br><br>";
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
Comment::createComment($myUser->getId(), $tweetToShow->getId(), $_POST['comment']);
}
}
echo "Ostatnie komentarze:<br>";
$allComments = Comment::loadAllComments($tweetIdToShow);
foreach ($allComments as $comment) {
$userIdToShow = $comment->getUserId();
$userToShow = User::getUserById($userIdToShow);
echo "<a href='show_user.php?userId={$userIdToShow}'>{$userToShow->getUserName()}:\n {$comment->getCommentText()}</a><br>";
echo "{$comment->getCommentDate()}<br><br>";
}
示例2:
echo "<a href='logout.php'>Wyloguj</a><br>";
echo "<a href='main.php'>Main</a><br>";
if (isset($_GET['tweetId'])) {
$tweetId = $_GET['tweetId'];
}
$tweetToShow = Tweet::ShowTweet($tweetId);
if ($tweetToShow !== false) {
echo "<h2>{$tweetToShow->getText()}</h2>";
echo "ID Tweeta: {$tweetToShow->getId()}<br>";
echo "Autor: {$tweetToShow->getIdUsera()}<br>";
echo "Data dodania: {$tweetToShow->getdataDodania()}<br>";
}
if ($_SERVER["REQUEST_METHOD"] === 'POST') {
$komentarz = Comment::Create($_SESSION['userID'], $tweetId, $_POST['trescKomentarza']);
}
$tweet = Tweet::getTweetById($_GET['tweetId']);
?>
<br>
<?php
echo "<form action = 'showTweet.php?tweetId={$tweet->getId()}' method='post'>";
?>
<label>
Dodaj Komentarz:
<br>
<input type="text" name="trescKomentarza">
</label>
</br>
<input type="submit">
</form>
<?php