Quantnet
12-20-2009, 02:17 AM
I have this script in /cron that will query the database and update the datastore
<?php
if (!is_object($vbulletin->db)) {
exit;
} else {
$db = &$vbulletin->db;
}
$totalapps = 0;
$programstats = array();
$appresult = $db->query_read("
SELECT programid
, COUNT(*) AS apps
FROM " . TABLE_PREFIX . "application
GROUP
BY programid
");
while ($program = $db->fetch_array($appresult)) {
$totalapps += $program['apps'];
$programstats[$program['programid']] = $program['apps'];
}
build_datastore(
'appstats',
serialize(array('total' => $totalapps, 'programs' => $programstats)),
true
);
I'd like to extend the query and datastore a bit by adding another query
$avgtime = $db->query_read("
SELECT programid,
ceil(avg((resultdate-datesubmitted)/86400)) as average
FROM application
where finalresult ="Admit" OR
finalresult ="Reject" AND
resultdate > 0
group by programid
");
Would anyone kindly advise me on how to put this extra query in the existing script and update the datastore so I can call the extra variables?
Thanks a lot
<?php
if (!is_object($vbulletin->db)) {
exit;
} else {
$db = &$vbulletin->db;
}
$totalapps = 0;
$programstats = array();
$appresult = $db->query_read("
SELECT programid
, COUNT(*) AS apps
FROM " . TABLE_PREFIX . "application
GROUP
BY programid
");
while ($program = $db->fetch_array($appresult)) {
$totalapps += $program['apps'];
$programstats[$program['programid']] = $program['apps'];
}
build_datastore(
'appstats',
serialize(array('total' => $totalapps, 'programs' => $programstats)),
true
);
I'd like to extend the query and datastore a bit by adding another query
$avgtime = $db->query_read("
SELECT programid,
ceil(avg((resultdate-datesubmitted)/86400)) as average
FROM application
where finalresult ="Admit" OR
finalresult ="Reject" AND
resultdate > 0
group by programid
");
Would anyone kindly advise me on how to put this extra query in the existing script and update the datastore so I can call the extra variables?
Thanks a lot