How to write custom SQL to query upcoming events, site notifications and site messages?

How to write custom SQL to query upcoming events, site notifications and site messages?

by wz z -
Number of replies: 3

Thank you very much! I investigated into the mdl_notificatoins, mdl_message tables, they seems have more content than I want. I just want those displayed in webpage rather than in emails.

And there is no such a table for upcoming events.  So please help me ~

Average of ratings: -
In reply to wz z

Re: How to write custom SQL to query upcoming events, site notifications and site messages?

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

You've already a block that do that for upcoming events.
You'll find all the code you need.
\blocks\calendar_upcoming

For the table is mdl_event

SELECT * from mdl_event WHERE timestart > extract(epoch from now()) -- for pgsql
SELECT * from mdl_event WHERE timestart > unix_timestamp(now()) -- for mysql

Hope it's helped.

Dominique.
Average of ratings:Useful (2)
In reply to Dominique Palumbo

Re: How to write custom SQL to query upcoming events, site notifications and site messages?

by wz z -
Thank you very much!
In reply to wz z

Re: How to write custom SQL to query upcoming events, site notifications and site messages?

by Taranveer Singh -
  • Click in the SQL Query area and type your SQL command. Optionally, double-click on a table name or field from the field list to include it in your query at the cursor location.
  • Click Run to run the query against your database. View the results in the Results area.
  • SQL Runner will load up to 5000 rows of the query’s result set.
  • For SQL dialects that support streaming, you can download the set from the sql server to access the full report.