Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /nfs/c01/h06/mnt/10927/domains/dragonprime.net/html/Sources/Load.php(225) : runtime-created function on line 3
Store Information
DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • September 18, 2019, 05:24:28 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Store Information  (Read 3638 times)
0 Members and 1 Guest are viewing this topic.
aes
Guest
« on: August 15, 2004, 12:24:51 PM »

Hi,

I'm creating a new module and want to know how I can store information in the database using a module or what the preferred mechanism is for holding persistent data.

If this is covered in the forums somewhere apologies for missing it.

Regards,
aes
Logged
anpera
Guest
« Reply #1 on: August 15, 2004, 12:39:10 PM »

You can use save_module_setting() and get_module_setting() for global module information or save_module_prefs() and get_module_prefs() for information like "usedtoday" to a specific user (even editable in user editor). Default values can be set with function <modulename>_install().

If you need an own table in database, you can use function <modulename>_install() to create the table automatically on every server.

See the example modules for how this all works. drinks.php is a good example for this.
« Last Edit: August 15, 2004, 12:39:53 PM by anpera » Logged
Kendaer
Guest
« Reply #2 on: August 15, 2004, 02:39:34 PM »

You can use save_module_setting() and get_module_setting() for global module information or save_module_prefs() and get_module_prefs() for information like "usedtoday" to a specific user (even editable in user editor). Default values can be set with function <modulename>_install().

If you need an own table in database, you can use function <modulename>_install() to create the table automatically on every server.

See the example modules for how this all works. drinks.php is a good example for this.

Actually, he means set_module_setting and set_module_pref, but basically yes.  There are examples of modules (riddle.php, dag.php, drinks.php) all of which create their own tables as well, but usually those tables should be for static data (like riddles and drinks).  Dag is an exception since there was a lot of info we needed to store about bounties, it made more sense to have a new table than to try and cram that into the usertable or the prefs table.

There is also the capability to store information against other types of objects in the database (see the darkhorse tavern and how it deals with mounts, so that that module provides the edit fields to allow mounts to be able to reach the tavern or not).  

Currently creatures, mounts, and drinks can have other modules provide additional features for them.  Weapons and armor dont just because of the sheer number of them :/ (IE, I was lazy) and the fact that they are very 'basic' things (they don't have any capabilities other than what they add to your attack/defense).

If you want to look at how some of that is done as well, look for module_objpref_edit and module_editor_navs in the various files and read the code for them in lib/modules.php
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

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