本文整理汇总了PHP中Tweet::createTweet方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::createTweet方法的具体用法?PHP Tweet::createTweet怎么用?PHP Tweet::createTweet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::createTweet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Tweet
<?php
if ($_SERVER["REQUEST_METHOD"] === 'POST') {
$newTweet = new Tweet();
$newTweet->createTweet($conn, $_SESSION["user_id"], $_POST["tweet"]);
}
?>
<hr>
<form method="post" action="#" style="padding: 20px">
<label>CREATE NEW TWEET</label><br>
<textarea name="tweet" placeholder="Enter tweet here"></textarea><br>
<label></label><br>
<input type="submit" value="Tweet">
</form>
<hr>
示例2:
<table class="table table-hover">
<thead>
<?php
echo "<H2>Hello {$myUser->getEmail()}</H2>\n <h4> Have nice day !!!</h4>";
?>
<tr>
<th>User Name</th>
<th>Dweet</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST)) {
Tweet::createTweet($myUser->getId(), $_POST['tweet']);
}
$allTweets = Tweet::loadAllTweets();
foreach ($allTweets as $tweet) {
echo "\n <tr>\n\n <td>";
$sql = "SELECT * FROM Users WHERE user_id = '{$tweet->getuserId()}';";
$result = $conn->query($sql);
if ($result->num_rows == 1) {
$row = $result->fetch_assoc();
echo $row['email'];
}
echo "\n <br> </td>\n <td>{$tweet->getText()}<br> </td>\n <td> {$tweet->getCreateDate()}<br></td>\n\n </tr>";
}
?>
</tbody>
</table>
示例3: Tweet
<?php
require_once "functions/function.inputSanitizer.inc.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['tweetText'])) {
$tweet = new Tweet($conn);
if (strlen($_POST['tweetText']) > 140) {
echo "Twój tweet jest za długi";
} else {
if (!$tweet->createTweet($user->getId(), sanitizeMySQL($conn, $_POST['tweetText']))) {
echo "BŁĄD!";
}
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['commentText'])) {
if (strlen($_POST['commentText']) > 5) {
$comment = new Comment($conn);
$comment->createComment($user->getId(), sanitizeMySQL($conn, $_POST['tweetID']), sanitizeMySQL($conn, $_POST['commentText']));
} else {
echo "Twój komentarz jest za krótki";
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['tweetDelete'])) {
$tweet = new Tweet($conn);
$tweet->loadFromDB(sanitizeMySQL($conn, $_POST['tweetDelete']));
$tweet->deleteTweet();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['commentDelete'])) {
$comment = new Comment($conn);
$comment->loadFromDB(sanitizeMySQL($conn, $_POST['commentDelete']));
$comment->deleteComment();
}