Example #1
0
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
        return $result;
    }
    public static function insert_into_chat($user_id, $room_id, $msg)
    {
        $stmt = static::$pdo->prepare("INSERT INTO chat(user_id, room_id, msg) VALUES (:user, :room, :m)");
        $stmt->execute(array("user" => $user_id, "room" => $room_id, "m" => $msg));
    }
    public function isvaildated_account($name)
    {
        $stmt = static::$pdo->prepare("SELECT name FROM user WHERE :name= name");
        $stmt->bindParam(':name', $name);
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
        if ($result == NULL) {
            return false;
        } else {
            return true;
        }
    }
    public function get_recent_chat($roomid)
    {
        $stmt = static::$pdo->prepare("SELECT msg, user_id FROM chat WHERE room_id=:room");
        $stmt->execute(array("room" => $roomid));
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
        return $result;
    }
}
Model::initiate();