Asynchronous Script Execution Or Threading ?

Depends how you have your urls routed but you could do something like this.




var sendEmail = function(email) {

  $.get('http://mysite/controller/action', {email: email, userid: id}).done(function(result) {

    if (result && email < 4) {

      sendEmail(email + 1);

    }

  });

};

sendEmail(1);



this should be done after some php validations.

can i call jquery inside php ?

can you further elaborate pls ?

i found a way to do this without a cron job… but sadly there is some issue. pls have a look http://www.yiiframework.com/forum/index.php/topic/36021-fsockopen-or-background-postget-methods/

I have the impression that you are absolutely on the wrong path, consider using a cron task.

Thanks zaccaria. there are 3 ways of achieving this task i found after some research.

1/ using ajax to send the emails… (the page load dropped to 1 second from 12 )

2/ to use the background process which i have mentioned here before.

3/ finally to use the cron job, i have been playing around cron job for all these while,

the reason why i choose to go with ajax is, its speed and i am being able shoot the emails at that moment it self rather sending from 5 minutes.

there is no any other concern which made me to choose ajax. simply the time of delivery and speed.

let me know if i am wrong. thanks all for helping me out… :)

Ajax is totally unreliable (user can close or go away from the page).

yeah i agree with you. but the way i am using it want affect me i believe. :)

as a merchant press update button, it will validate and afterwards, page will reload. after that email will be send behind the screen…

as the page loads, it shoots the email.

is there any chances of falling off the boat with my way ???

thanks

And if something goes wrong (mailer is down, browser crash, javascript error, etc) the letters will not be sent at all.

Once again: this it totally unreliable.

But of course you can do whatever you want. It’s yours application after all, not mine.

To run php script mulit-threaded / async, please take a look at http://php.net/manual/de/function.pcntl-fork.php

This is possible wioth php, even there is no special Yii equivalent.

Ok cool. thanks for the feedback ORey. appreciate them. :)

let me re think of a way.

tnx again dude. :)

Maybe the extension runactions can help you with time consuming tasks. I use it on sending emails too.