Userdata functions

From Sohowiki
(Difference between revisions)
Jump to: navigation, search
m
m
Line 73: Line 73:
 
[http://www.gambling-online-theory.com/casinos/casinos-strategy.html casinos strategy]
 
[http://www.gambling-online-theory.com/casinos/casinos-strategy.html casinos strategy]
 
[http://www.magical-casino.com/casino_risk.html Gambling Online - Risks.]
 
[http://www.magical-casino.com/casino_risk.html Gambling Online - Risks.]
 +
 +
 +
 +
[http://www.gambling-online-theory.com/casinos-portal/best-casinos-online.html best casinos online]
 +
[http://www.casinos-go.com/online-casino-tips/online-casino-on-the-net.html online casino on the net]
 +
[http://www.casino-theory.com/online-casino-royale/strategy-online-casino.html strategy online casino]
 +
[http://www.casino-theory.com/online-casino-bonus/online-casino-net.html online casino net]
 +
[http://www.casino-games-wiki.com/index.php/casino_games_game casino games game]
 +
[http://www.casino-games-wiki.com/index.php/on_line_casino_games on line casino games]
 +
[http://www.online-casino-wiki.com/index.php/online_casino_tips online casino tips]
 +
[http://www.3wcasinos.com/roulette-tips/index.html roulette tips]
 +
[http://www.casino-web-gambling.com/blackjack-tips/blackjack-hints.html blackjack hints]
 +
[http://www.casino-theory.com/online-casino-bonus/online-casino-net.html online casino net]

Revision as of 17:01, 24 November 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.

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'];


roulette tips slots online online casino tips Casino rules. online casino net Online casino games. online casino tips Bonuses in Online Casinos. casinos strategy Gambling Online - Risks.


best casinos online online casino on the net strategy online casino online casino net casino games game on line casino games online casino tips roulette tips blackjack hints online casino net

Personal tools