简体   繁体   English

在Codeigniter中在后台调用另一个方法名称

[英]Calling another method name in background in Codeigniter

I am new to background processes in Codeigniter. 我对Codeigniter中的后台进程不熟悉。 I thought CURL would help me in executing a method name. 我以为CURL可以帮助我执行方法名称。

Basically, My website is sending a mail to admin(me) whenever an user drops a msg. 基本上,每当用户删除msg时,我的网站都会向admin(me)发送一封邮件。 My controller method inserts in the database and executes Curl library (calls another method name) for background execution so that user doesn't have to wait until the mail has been sent. 我的控制器方法插入数据库中,并执行Curl库(调用另一个方法名称)以进行后台执行,因此用户不必等到发送邮件之后。 I tried CURL library by Phil Sturgeon but my hard luck. 我尝试了Phil Sturgeon的CURL库,但我很不幸。

Help appreciated. 帮助表示赞赏。 Thanks a lot. 非常感谢。

curl is not going to run a method in the background. curl不会在后台运行方法。 If you want to run background jobs in php, you would need to use the command line / exec() . 如果要在php中运行后台作业,则需要使用命令行/ exec()

However, a more solid way to add jobs in the background - if sending mail really takes that long - would be to add the message to a message queue in a database and schedule a job (using cron on linux for example) that checks the queue periodically for messages to be sent. 但是,在后台添加作业的一种更可靠的方法(如果发送邮件确实需要那么长的时间)将是将邮件添加到数据库中的邮件队列中,并安排检查队列的作业(例如,在Linux上使用cron)定期发送消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM