101 lines
1.9 KiB
PHP
101 lines
1.9 KiB
PHP
<?php
|
|
include_once('class.Database.php');
|
|
class Tweet extends database
|
|
{
|
|
public $id;
|
|
public $tweet_text;
|
|
public $created_at;
|
|
public $user_id;
|
|
public $profile_img;
|
|
public $status;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->id = '';
|
|
$this->tweet_text='';
|
|
$this->created_at='';
|
|
$this->user_id='';
|
|
$this->profile_img='';
|
|
$this->status='';
|
|
}
|
|
|
|
public function saveTweet()
|
|
{
|
|
$qry="INSERT INTO tweets
|
|
SET
|
|
tweet_id='".$this->id."',
|
|
tweet_text='".$this->tweet_text."',
|
|
created_at='".$this->created_at."',
|
|
user_id='".$this->user_id."'";
|
|
|
|
parent::executeQuery($qry);
|
|
}
|
|
|
|
public function updateTweet()
|
|
{
|
|
$qry="UPDATE tweets
|
|
SET
|
|
tweet_text='".$this->tweet_text."',
|
|
created_at='".$this->created_at."',
|
|
user_id='".$this->user_id."'
|
|
WHERE tweet_id='".$this->id."' ";
|
|
|
|
parent::executeQuery($qry);
|
|
}
|
|
|
|
public function getAllTweetIds()
|
|
{
|
|
$qry="SELECT tweet_id FROM tweets WHERE is_deleted='N'";
|
|
|
|
parent::executeQuery($qry);
|
|
$qryRes=parent::asObject();
|
|
|
|
if($qryRes)
|
|
{
|
|
return $qryRes;
|
|
}
|
|
}
|
|
|
|
public function updateTweetStatus()
|
|
{
|
|
$qry="UPDATE tweets
|
|
SET
|
|
is_deleted='".$this->status."',
|
|
deleted_at=NOW()
|
|
WHERE tweet_id='".$this->id."'";
|
|
|
|
parent::executeQuery($qry);
|
|
}
|
|
|
|
//Function get Latest Tweet of a user
|
|
public function getLatestUserTweet()
|
|
{
|
|
$qry="SELECT tweet_id FROM tweets WHERE user_id='".$this->user_id."' ORDER BY tweet_id DESC LIMIT 1";
|
|
|
|
parent::executeQuery($qry);
|
|
$qryRes=parent::asObject();
|
|
|
|
if($qryRes)
|
|
{
|
|
return $qryRes;
|
|
}
|
|
}
|
|
|
|
public function getDeletedTweets()
|
|
{
|
|
$qry="SELECT u.screen_name,u.name,u.profile_image_url,t.tweet_id,t.tweet_text
|
|
FROM tweets AS t
|
|
LEFT JOIN users AS u ON u.user_id=t.user_id
|
|
WHERE t.is_deleted='Y'
|
|
ORDER BY t.tweet_id DESC";
|
|
|
|
parent::executeQuery($qry);
|
|
$qryRes=parent::asObject();
|
|
|
|
if($qryRes)
|
|
{
|
|
return $qryRes;
|
|
}
|
|
}
|
|
}
|
|
?>
|