Closed ghost closed 5 years ago
I don't know why you use query()
like this. Using query()
to execute custom query without quotation from pdo object is not the way we recommended.
Please read our documentation about how to create custom query and consider using quotation syntax instead.
Thank you very much for your answer. I am probably a bit confused. Maybe the method used is wrong. I will try other methods again later, thank you again for your answer.
@catfan Sorry, I am bothered, I still want to ask a question.
When I use PDO->query
, I can create event scheduling tasks.
When I use medoo->query
, I can't create event scheduling tasks.
Please see the screenshot below.
Results of two executions
Looking forward to your reply!
Did you really read the documentation and the link I replied above? Especially the quotation warning for custom query.
There is nothing I can help if you still using like this way.
@catfan
I am very sorry, I have learned the lesson.
But I can't create it using the following method, but also use debug()
to print it out. Maybe I still don't know how to write it. Please give me some help.
thank you very much.
Medoo SQL
$order_number = 'O'.date('YmdHis').rand(100000, 999999);
$database->debug()->query('CREATE DEFINER = <root>@<localhost> EVENT <' . $order_number . '> ON SCHEDULE AT : dateTime ON COMPLETION NOT PRESERVE ENABLE DO call closeTrade(: order);', [
': dateTime' => date('Y-m-d H:i:s', strtotime("+1 day")),
': order' => $order_number
]);
Print result
CREATE DEFINER = `root`@`localhost` EVENT `O20190523101243432968` ON SCHEDULE AT '2019-05-24 10:12:43' ON COMPLETION NOT PRESERVE ENABLE DO call closeTrade('O20190523101243432968');
Looking forward to your reply.😊😊
@catfan After trying N times, I finally succeeded. I used the following method.
$order_number = 'O'.date('YmdHis').rand(100000, 999999);
$my_db->query("CREATE DEFINER = <root>@<localhost> EVENT <$order_number> ON SCHEDULE AT :dateTime ON COMPLETION NOT PRESERVE ENABLE DO call closeTrade(:order);", [
':dateTime' => date('Y-m-d H:i:s', strtotime("+1 day")),
':order' => $order_number
]);
:variable
No spaces can be used in the middle.
I am very sorry, this is the problem caused by my mistake and I am very grateful for your answer.😊😊
@programmexwz Congratulations on your success. Additionally, there is no need for the last ;
.
我在使用medoo的过程中遇到一个问题,但是我无法自己解决,使用
$database->pdo->setAttribute(***)
我无法创建mysql的event定时任务,想知道是否是我自己用错了,请您看到后务必回复我一下,下面直接上截图。再次感谢。