public static function of($user) { if (!self::$db) { self::$db = MySQL_Database::instance(); } $sql = 'SELECT s.status, s.message, s.user_id FROM ' . MYSQL_PREFIX . 'status AS s'; if (is_int($user) || 1) { $sql .= ' WHERE s.user_id = :user'; } else { $sql .= ' LEFT JOIN ' . MYSQL_PREFIX . 'users AS u ON u.user_id = s.user_id WHERE u.username = :user'; } $sql .= ' LIMIT 1'; $prep = self::$db->prepare($sql); $prep->execute(array(':user' => $user)); $status = $prep->fetch(PDO::FETCH_OBJ); return new Status($status->user_id, $status->status, $status->message); }
function __construct($user_id, $s = null, $message = '') { self::$db = MySQL_Database::instance(); $this->s = $s; $this->message = $message; $this->user_id = $user_id; }