The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Help with saving sql query results
Fixed post.....
|
#2
|
|||
|
|||
You could do something like this:
Code:
$result = $vbulletin->db->query("SELECT userfield.fieldX, userfield.userid FROM userfield INNER JOIN user ON user.userid =userfield.userid WHERE usergroupid IN (list_of_usergroups)"); $rendered_table = '<table>'; while ($row = $vbulletin->db->fetch_array($result)) { $rendered_table .= '<tr><td>' . $row['userid'] . '</td><td>' . $row['fieldX'] . '</td></tr>'; } $rendered_table .= '</table>'; vB_Template::preRegister('template_name', array('rendered_table' => $rendered_table)); then use {vb raw rendered_table} in the template. (This assumes you want to put it in an existing template. If you're creating your own template then you'd probably use register() instead of preRegister()). Quote:
That's what the above example does, and there's no problem doing it that way. But I should mention that the convention in the vbulletin code is to put any html in a template and render the template. You could have a template for one table row, or you can save all the rows to an array and then use <vb:each> in the template to loop through them. |
#3
|
||||
|
||||
Quote:
My mod reads an external XML API file that retrieves values to use for the table i mentioned. But it's pretty intensive, generating the table for 5 test users currently takes ~30 seconds. So what i was thinking was to use a cron job that runs every 10 or 15 minutes with a script that opens the API, saves the values in the database (i've already managed to do this ) so that when the actual script (mymod.php) is requested, it just has to read and output the values that were already saved in the database instead of having to run the API. What i need help with is caching the to make it run faster. Thanks again! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|