开发者

Caching Queries / Temp Tables for PHP and MySQL

I have a class that handles user registration. There are two main steps: inserting users into a mysql table, and then sending a confirmation e-mail if the insert is successful.

Is there any way that I can...I don't k开发者_JAVA技巧now...sort of cache the first step so that data is not inserted if the the function that handles sending the e-mail fails?

I can check to see if sendmail is enabled on the server, and if not then not even perform the query. I think that would work most of the time, but I also want to catch the times when sendmail is enabled but there's just some error with sending the e-mail.

I though of inserting all data into a temp table, and if the mail send is successful copying the row into the permanent table. The problem with this is that I am calling a stored procedure to insert data, and the mail stuff is happening in application code, so as soon as the insert is done, a temp table would autodelete (is that correct?).


I personally do not send emails from the application. Instead I store the email info in a table, use a cron job to send the emails from the table that way I can take appropriate actions.


Either use Dan's solution "LAST_INSERT_ID()" or in case you first INSERT all users and sending out the email later simply cache the ID to its corresponding user email in order to delete the user by its reference:

array('sample@domain.com' => 123);

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜