PHP
I have an question here. I'm using the below query. I'm using the loop to run this query ?
How can i run this query without loop ?
I don't want to run the queries in foreach ? how can i do that ?
Am i using the correct method to run this query ?
It takes time to load. Is there any optimized to achieve this ?
I need perform a multi-query to run them all at once?
<?php
$year = "2016";
$start = new DateTime($year.'-01-01');
$start->modify('first day of this month');
$end = new DateTime($year.'-12-31');
$end->modify('first day of next month');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt) {
$calcstart_date = $dt->format("Y-m-d").' 00:00:00';
$calcend_date = $dt->format("Y-m-t").' 11:59:00';
$month_name = $dt->format('M');
$test_submitted_query = db_query("
SELECT requester_id, email, username, is_dashboard_user, SUBMITTED_ON
FROM testing_a, aspusers a
WHERE requester_id=a.user_id
AND AD_MAIL_ATTRIBUTE IS NOT NULL
AND IS_DASHBOARD_USER = 'y'
AND SUBMITTED_ON >= timestamp '$calcstart_date'
AND SUBMITTED_ON <= timestamp '$calcend_date'
");
}
?>