我有foreach
的大功能,可以发出800多个MySQL请求。
它在5-6秒内执行。调用此函数F1
。
所以这样:
function F1(){
foreach($current_id as $id){
request (SELECT * FROM wp_posts o LEFT OUTER JOIN wp_posts r ON
o.post_parent = r.ID WHERE r.id = '$id' AND o.post_type = 'product')
request (update wp_postmeta
set meta_value = $val
where meta_key in ('_price','_regular_price') and post_id IN
(select tempP.tempId from(
select v.id as tempId from wp_posts v join wp_postmeta pm on (pm.post_id =
v.id) join wp_posts p on (v.post_parent = p.id) where meta_key ='_price' and
v.post_type = 'product_variation' and p.id = '$id') as tempP))
request (UPDATE simple request very short)
}
}
我想再添加一个函数F2
来发送电子邮件,所以我需要近400个短的MySQL请求来检查表中元素的DataBASE ID,如果存在,那么发送电子邮件给人。
问题是:哪里最好拨打F2在F1或外面发送电子邮件?
VAR 1:
function F1(){
foreach($current_id as $id){
request (SELECT with INNER JOIN 0, 002 sec)
request (UPDATE with inner JOIN near 0,04)
request (UPDATE simple request very short)
if($id is){
so call function F2(){
send email
}
}
}
}
VAR 2:
function F1(){
foreach($current_id as $id){
request (SELECT with INNER JOIN 0, 002 sec)
request (UPDATE with inner JOIN near 0,04)
request (UPDATE simple request very short)
if($id is){
$array_ids = array_merge($id);
}
}
}
if (!empty($array_ids)){
explode;
foreach ($find_id as id){
so call function F2(){
send email
}
}
}
或者它是更好的解决方案吗?