Reputation: 5407
I checked event scheduler is off on my phpmyadmin. My site is live, i dont know making event scheduler on
can create any bad effect ?
I want to create event which should execute every morning, fetch some value from table and show on the page.
CREATE EVENT rate ON SCHEDULE EVERY 24 HOUR STARTS '2011-12-01 8:00:00' DO BEGIN
END
query I want to execute inside event is :
SELECT url,sentiment, count(url) from userpost where userid='".$userid."' group by url order by count(url) desc;
I am confused.
Event will be created on phpmyadmin. query should be executed on php page to get the values to be shown on the page.
how can manage this scenario?
Upvotes: 2
Views: 2644
Reputation: 29051
You have to change the state of event_scheduler variable to ON
.
Run below query on phpmyadmin
SET GLOBAL event_scheduler = ON;
EDIT::
You have to create a php page that can be called by windows scheduler every day at 8 AM and then on your page you can directly call your query. You can't use mysql event scheduler to perform this action. You can do it with windows scheduler or some other applications.
Upvotes: 1
Reputation: 92785
It looks like you're a little bit confused on the purpose of MySQL events or any event scheduler for that matter. It's used for batch processing and has no means to return any resultset to the client on its own.
CREATE EVENT Syntax
Statements such as SELECT or SHOW that merely return a result set have no effect when used in an event; the output from these is not sent to the MySQL Monitor, nor is it stored anywhere. However, you can use statements such as SELECT ... INTO and INSERT INTO ... SELECT that store a result. (See the next example in this section for an instance of the latter.)
Now if you need to execute your query from the php page then go ahead and do that.
On the other hand if you want to pre-calculate some resultset(s), which is(are) resource intensive, you can use INSERT INTO ... SELECT ... FROM ...
syntax and an event to execute it and store results in a table. And then from php page just fetch and present them from that table.
Upvotes: 1