Am looking at executing all DB queries in parallel.
My current code looks as below
mysql_connect("host", "user", "pass");
$dbcheck = mysql_select_db("db");
if ($dbcheck) {
/* BLOCK - 1*/
$result_1 = mysql_query($query1);
if (mysql_num_rows($result_1) > 0) {
while ($row_1 = mysql_fetch_assoc($result_1)) {
$a=$row_1["AA1"];
$b=$row_1["AA2"];
$a[]="['".$a."',".$b."]";
}
}
/* BLOCK - 2*/
$result_2 = mysql_query($query2);
if (mysql_num_rows($result_2) > 0) {
while ($row_2 = mysql_fetch_assoc($result_2)) {
$ac1=$row_2["ab1"];
$ac2=$row_2["ab2"];
$chart_array_2[]="['".$ac1."',".$ac2."]";
}
}
}
The above runs sequentially I believe. What I'd like to do is execute 'BLOCK - 1' & 'BLOCK - 2' in parallel. I have about 20 such blocks. I'd like to kick them all off in parallel.
I've looked on google. Most of them talk about running DB queries in parallel. I'm not able to figure out a way to implement that with my requirement. Is there a way in PHP that I can kick off each of the blocks in parallel please?