DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • September 02, 2010, 09:45:04 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: Sql-results pass-over  (Read 903 times)
0 Members and 1 Guest are viewing this topic.
Nightborn
Guest
« on: September 05, 2005, 01:42:50 AM »

this might sound stupid, but... well...

what's the best way to pass a sql-result from a db_query over to the next run of this module?

i.e. if I make a query...then the module ends and the user clicks the nav to execute another command (in the module) ... I want to keep the results to save processor time.

the _run has no arguments to pass over (and I would have to call the function again)

Any help? thanks
« Last Edit: September 05, 2005, 01:43:09 AM by Nightborn » Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #1 on: September 05, 2005, 02:17:27 AM »

what kind of information do you have? if it is only 1 value, you could pass is via $session['user']['specialmisc']...
If there are more values / an array I'd serialize an array and store that array-string in above mentiond var...
but unserializing an arraystring takes a little time, too...
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #2 on: September 05, 2005, 02:35:43 AM »

I need to pass over the entire results of a query who have 3 fields...

sql the untranslated table with tid, namespace, intext

and then pass it over..well... might be 50 rows or more, depends on your table.

hm, if unserialize is faster than the sql query, it would make sense to stick to the old method: make a new query
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #3 on: September 05, 2005, 03:00:08 AM »

OR...

put these values into a hidden-field of any HTML-form, send them via POST and so on... It's definately faster than querying the SQL-server... but naming the fields is difficult... hmmm
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #4 on: September 05, 2005, 03:01:53 AM »

hm. yes... Sad plain text would be easy, but an entire sql query... hmm.
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #5 on: September 05, 2005, 03:16:18 AM »

while ($row = db_fetch_assoc($result))
 $stack = array_push($stack, $row);
$string = serialize($stack);
$session['user']['specialmisc'] = $string;

------------------

$stack = unserialize($session['user']['specialmisc'];
unset($session['user']['specialmisc']);
while(list($key, $entry) = each($stack)) {
do_code();
}

===================================
That should work...
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #6 on: September 05, 2005, 03:19:21 AM »

okay, thanks, I'll try it ... (after I bought my food now...hehe)

Logged
Nightborn
Guest
« Reply #7 on: September 05, 2005, 06:05:20 AM »

Okay, I tried it... but there was no speed improvement Sad

it worked fine, I did:
 
Code:
   
 //header
   $stack=array(); //needed if specialmisc is empty
   $stack = unserialize($session['user']['specialmisc']); //TEST
   unset($session['user']['specialmisc']); //TEST
       
//the sql query...if it is necessary
                                               if ($checked=="")  //if there are results before, submit button
                  {
                  $result = db_query($sql);
                  }
                  else
                  {
                  $result=$stack;
                  //unserialize ($stack);
                  $stack=array();   //faster
                  }
//and within the db_fetch
                  array_push($stack, $row);   //TEST

//and after the while
               $session['user']['specialmisc'] = serialize($stack); //TEST



a pity it didn't get me the necessary speed. Sad
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #8 on: September 05, 2005, 06:43:29 AM »

I did not say, it'll speed your server up... it just works... Smiley

serialize/unserialize are quite complicate functions...

But except fetching all the values again from your database, there's no real alternative... maybe except storing the values in POST-vars...
Logged

Running for more than three years now:
Nightborn
Guest
« Reply #9 on: September 05, 2005, 06:52:44 AM »

hm, yes. Smiley

single values are stored in post vars currently... it's about the translation wizard I am currently working on from time to time...

I just want to make translations as easy as possible... hm...


the select from .... where ... in ... is not working on the sql version of theKlaus ... he says he has some 4 version (didn't look that up). is there a option to it?
I implemented the query you told me once Wink to translate already translated texts
Logged
GenmaC
Moderator
Codemeister
*****
Offline Offline

Posts: 422

Coder


View Profile WWW
« Reply #10 on: September 08, 2005, 02:37:46 PM »

I once coded a CMS based on the idea of saving the db calls, and it's really not worth it.  Just make the SQL calls as many times as you need to, as there's not much point in saving the results from the fairly simple SQL results you'll be getting working with LoGD.
Logged



Castle Siege - a work in progress
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Who's Online
31 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search