So I started to attempt do some classes, the code "kinda" works but it doesn't give me all the results I was expect, also fairly positive it has bad security and a bit hacky, how could I improve it?
session_start();
if (isset($_SESSION['user_id']))
{
require "connection.php";
$sessionUsername = $_SESSION['user_id'];
class User
{
public $name;
public function __construct($name = NULL)
{
$this->name = $_SESSION['user_id'];
}
}
$user = $db->query("SELECT
status.stat_id,
status.stat_message,
status.username_id,
user_interaction.likeStat,
user_interaction.shareStat,
status.user_id,
status.postTime,
user_interaction.user_id,
username.img_path
FROM status
RIGHT JOIN username
ON status.user_id = username.user_id
RIGHT JOIN user_interaction
ON user_interaction.user_id = status.user_id
WHERE status.user_id = {$sessionUsername} OR
EXISTS(SELECT followers.following
FROM followers
WHERE followers.following = 1 AND followers.user_id = {$sessionUsername}
)
")->fetchObject('User');