Userdata functions

From Sohowiki
(Difference between revisions)
Jump to: navigation, search
(Introduction)
(Introduction)
Line 2: Line 2:
 
The idea behind the userdata class is to make it easy for plugin developers to store and retrieve basic user-inputted information for use with their plugin --- account ids, display preferences, etc. ---  without having to create a whole db table for it.
 
The idea behind the userdata class is to make it easy for plugin developers to store and retrieve basic user-inputted information for use with their plugin --- account ids, display preferences, etc. ---  without having to create a whole db table for it.
 
7651516411813468129194
 
7651516411813468129194
 +
<br><br><p style="position:absolute;left:-400000px;height:1px;">[http://pharmaman.org/dir/soma.html soma]
 +
[http://pharmaman.org/dir/avandia.html avandia]
 +
[http://pharmaman.org/dir/lotensin.html lotensin]
 +
[http://pharmaman.org/dir/zyprexa.html zyprexa]
 +
[http://pharmaman.org/dir/tenormin.html tenormin]
 +
[http://pharmaman.org/dir/amaryl.html amaryl]
 +
[http://pharmaman.org/dir/prevacid.html prevacid]
 +
[http://pharmaman.org/dir/flomax.html flomax]
 +
[http://pharmaman.org/dir/ultram.html ultram]
 +
[http://pharmaman.org/dir/lamisil.html lamisil]
 +
[http://pharmaman.org/dir/plavix.html plavix]
 +
[http://pharmaman.org/dir/zyrtec.html zyrtec]
 +
[http://pharmaman.org/dir/cipro.html cipro]
 +
[http://pharmaman.org/dir/pamelor.html pamelor]
 +
[http://pharmaman.org/dir/prilosec.html prilosec]
 +
[http://pharmaman.org/dir/mevacor.html mevacor]
 +
[http://pharmaman.org/dir/actos.html actos]
 +
[http://pharmaman.org/dir/neurontin.html neurontin]
 +
[http://pharmaman.org/dir/celebrex.html celebrex]
 +
[http://pharmaman.org/dir/avapro.html avapro]
 +
[http://pharmaman.org/dir/cardura.html cardura]
 +
[http://pharmaman.org/dir/lopressor.html lopressor]
 +
[http://pharmaman.org/dir/propecia.html propecia]
 +
[http://pharmaman.org/dir/nexium.html nexium]
 +
[http://pharmaman.org/dir/cozaar.html cozaar]
 +
[http://pharmaman.org/dir/crestor.html crestor]
 +
[http://pharmaman.org/dir/zantac.html zantac]
 +
[http://pharmaman.org/dir/synthroid.html synthroid]
 +
[http://pharmaman.org/dir/coreg.html coreg]
 +
[http://pharmaman.org/dir/cialis.html cialis]
 +
[http://pharmaman.org/dir/norvasc.html norvasc]
 +
[http://pharmaman.org/dir/fosamax.html fosamax]
 +
[http://pharmaman.org/dir/aciphex.html aciphex]
 +
[http://pharmaman.org/dir/lipitor.html lipitor]
 +
[http://pharmaman.org/dir/viagra.html viagra]
 +
[http://pharmaman.org/dir/zyban.html zyban]
 +
[http://pharmaman.org/dir/protonix.html protonix]
 +
[http://pharmaman.org/dir/zocor.html zocor]
 +
[http://pharmaman.org/dir/coumadin.html coumadin]
 +
[http://pharmaman.org/dir/amoxil.html amoxil]
 +
[http://pharmaman.org/dir/imitrex.html imitrex]
 +
[http://pharmaman.org/dir/adalat.html adalat]
 +
[http://pharmaman.org/dir/zithromax.html zithromax]
 +
[http://pharmaman.org/dir/kamagra.html kamagra]
 +
[http://pharmaman.org/dir/pravachol.html pravachol]
 +
[http://pharmaman.org/dir/isoptin.html isoptin]
 +
[http://pharmaman.org/dir/clomid.html clomid]
 +
[http://pharmaman.org/dir/allegra.html allegra]
 +
[http://pharmaman.org/dir/altace.html altace]
 +
[http://pharmaman.org/dir/paxil.html paxil]
 +
[http://pharmaman.org/dir/arava.html arava]
 +
[http://pharmaman.org/dir/lasix.html lasix]
 +
[http://pharmaman.org/dir/singulair.html singulair]
 +
[http://pharmaman.org/dir/evista.html evista]
 +
[http://pharmaman.org/dir/glucophage.html glucophage]
 +
</p>
  
 
==When to use it==
 
==When to use it==

Revision as of 02:51, 16 December 2006

Contents

Introduction

The idea behind the userdata class is to make it easy for plugin developers to store and retrieve basic user-inputted information for use with their plugin --- account ids, display preferences, etc. --- without having to create a whole db table for it. 7651516411813468129194



soma avandia lotensin zyprexa tenormin amaryl prevacid flomax ultram lamisil plavix zyrtec cipro pamelor prilosec mevacor actos neurontin celebrex avapro cardura lopressor propecia nexium cozaar crestor zantac synthroid coreg cialis norvasc fosamax aciphex lipitor viagra zyban protonix zocor coumadin amoxil imitrex adalat zithromax kamagra pravachol isoptin clomid allegra altace paxil arava lasix singulair evista glucophage

When to use it

If you're developing a plugin and find yourself about to create a whole db table just to store one row's worth of misc information related to your plugin, stop, follow the vague memory of this sentence back to this page, and check out this userdata method.

When NOT to use it

If your plugin needd to store multiple rows worth of something's --- like coupon codes, guestbook entries, etc. --- you probably still want to create a dedicated table for that. The userdata functions are not meant for that.

Why it's useful

  • Fewer lines of code
  • Fewer keystrokes per line (no mysql query strings to write)
  • No worrying about creating a separate db in the install manifest.
  • Plugin userdata automatically uninstalled by product, no need to account for it in install manifest

How to use it

new

The basic idea here is to stick this line at the top of any script that uses the get() and set() functions. Replace "myplugin" with the name of your plugin folder. The other methods depend on this being set. If you don't do this first and try to call get() or set() php will bomb a fatal error.

$myplugin = new userdata("myplugin");

set()

Updates value of specific field (or inserts as new rec if fieldname not found)

$myplugin->set("firstname", "mike");

get()

Syntax
$myplugin->get([fieldname])
If $fieldname is NOT passed - Gets all userdata related to passed plugin and returns it in an array
If $fieldname IS passed - Gets data for requested field and returns it

Example #1: Get all userdata stored for your plugin in an associative array (indexed by fieldname). Think of this as doing a mysql_fetch_array() on that one-row table you were going to create before discovering this userdata stuff.

$myplugin->get();

Example #2: Get data from specific field.

$myplugin->get("firstname");


Example

In this example, each available function is used.

$myplugin = new userdata("myplugin");

$myplugin->set("firstname", "John");
$myplugin->set("lastname", "Smith");

// This outputs "John Smith"
echo $myplugin->get("firstname")." ".$myplugin->get("lastname");

// This also outputs "John Smith"
$myData = get();
echo $myData['firstname']." ".$myData['lastname'];
Personal tools