• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

QUESTION can't load data from external mysql DB into page

cohiba

New member
Messages
2
Likes
0
Points
1
#1
hi guys,

so far i used the old insert_php tag, to load a database into an array, but the "real" code was written in an extra php file
Code:
[insert_php] $lang="de"; include('.php/speisen_laden.php'); [/insert_php]
later, but on the same page, i load another php-file passing a category, which generates different lists , depending on the cat Variable
Code:
[insert_php] $cat=52; include('.php/speisen.php'); [/insert_php]
so far so good - the array was generated once and then this array was used to generate different lists. this is used to generate a complete restaurant menu. each section

using the woody plugin, this doesn't work anymore, by including those separate files. my code even doesn't work if i load the database directly in one snippet and generating the list by using the array, at the another snippet.

obviously, i can't pass variables between two snippets, right?

so actualy the only way to generate my categorydepending lists is to load the database and generate the array on each list-generation, which costs loadingtime!

any idea on loading the list/array once, to use in several following snippets?
 

Kirill

Support team
Messages
82
Likes
4
Points
8
#3
hi
obviously, i can't pass variables between two snippets, right?
yes, the snippets were designed as isolated units.

To avoid duplicate queries to the database, you can use the cache.
If you not use cache plugins then cached data will be stored only during the current request to the site. This is enough to pass between snipples.
If you use cache plugins then the cache lifetime is specified in the plugin settings.This can be useful and it will speed up the site. And will suit you if only you do not need to show data in real time.
WP_Object_Cache

Best regards, Kirill
Webcraftic team