Userdata functions

From Sohowiki
Revision as of 04:51, 16 December 2006 by 81.177.14.26 (Talk)
Jump to: navigation, search

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



matter penis size woman does forum matter penis size penis size matter does penis size matter does penis size matter to woman does matter penis really size penis preference size woman matter penis size woman woman and penis size penis size and what woman like cock size penis size woman want woman talk about penis size discuss penis size woman opinion penis size woman womens opinion on penis size ideal penis size penis size prefer woman penis size view woman penis size survey woman penis size what woman want what woman think about penis size penis say size woman ideal penis size woman penis enlargement exercise program enlargement exercise free penis program enlargement exercise free penis program exercise free penis program penis exercise program penis enlargement program penis enlargement exercise program natural pennis enlargement exercise free penis program free pennis enlargement free penis enlargement program penis enlargement program free penis enlargement exercise program penis stretching exercise penis stretching exercise penis pills size exercise free penis stretching pennis enlargement pills pennis stretching improve penis length increase penis length penis enlargement traction device pennis pills enlargment pennis pills penis enlargement device exercise free penis stretching pennis stretching penis enlargement device stretching penis lengthening exercise device enlargement make penis enlarge penis length penis enlargement stretcher penile stretching penis enlargement device stretching penis enlargement device home made penis enlargement device the best penis enlargement system device enlargement make penis homemade penis enlargement device device enlargement penile the best enlargement penis device penis enlargement traction device penis enlargement forum enlargement forum penis pills does forum matter penis size enlargement forum penis pills enlargement forum penis pill free penis enlargement forum exercise forum penis enlargement forum free matter penis size exercise forum penis penis enlargement forum enlargement forum free matter penis size free penis enlargement forum enlargement forum penis pill penis size forum penis pills forum penis pill forum penis enlargement

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