Userdata functions

From Sohowiki
(Difference between revisions)
Jump to: navigation, search
m
m (Reverted edit of JvaMy7, changed back to last version by Soho)
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
[http://chaba.info/barbecue-elettrico/ barbecue elettrico] [http://nobinters.org/lg-lcd.htm lg lcd 26] [http://helmed.info/topic/herny/ herny] [http://nobinters.org/barra-grande.htm barra grande itaipu de fora ba] [http://nobinters.org/sardegna-piantina.htm sardegna piantina] [http://chaba.info/televisori-jvc/ televisori jvc lcd 26] [http://ashythro.info/library/html/free-gp/ free 3gp porn video] [http://ustall.org/web/aklan.htm aklan] [http://psisemiya.com/images/small/www-centro/ www centro d abruzzo it] [http://psisemiya.com/images/small/albergo-quebec/ albergo quebec] [http://chaba.info/fara-in/ fara in sabina] [http://nobinters.org/libri-di.htm libri di decorazioni] [http://bloprofeldi.info/lib/cd-beethoven.htm cd beethoven] [http://ustall.org/web/prefettura-viterbo.htm prefettura viterbo] [http://helmed.info/topic/giochi-consolle/ giochi consolle] [http://nobinters.org/telefax-segreteria.htm telefax segreteria] [http://nobinters.org/astyle-abbigliamento.htm a-style abbigliamento] [http://psisemiya.com/images/small/samsung-videocamere/ samsung videocamere mini stick] [http://davte.info/library/html/calcilutite.htm calcilutite] [http://saibso.org/diesel-giacconi.htm diesel giacconi] [http://saibso.org/delon-karena.htm delon karena cinta] [http://davte.info/library/html/tam-automazione.htm tam automazione srl] [http://amohseni.info/img/styles/conqueror-/ conqueror 1086 a.d.] [http://ustall.org/web/un-fiume.htm un fiume di dollari] [http://ashythro.info/library/html/sites-xxx/ sites xxx] [http://ustall.org/web/canon-a.htm canon a 300] [http://kinunia.cn/bic-ruga.htm bic ruga] [http://helmed.info/topic/pesca-apnea/ pesca apnea] [http://bloprofeldi.info/lib/tv.htm tv 42] [http://nobinters.org/via-show.htm via show] [http://davte.info/library/html/ivete-zangalo.htm ivete zangalo] [http://bloprofeldi.info/lib/vacanza-benessere.htm vacanza benessere trentino] [http://bloprofeldi.info/lib/sintoamplificatori-av.htm sintoamplificatori av] [http://nobinters.org/altec-lansing.htm altec lansing auricolari e cuffie] [http://kinunia.cn/prestito-veneto.htm prestito veneto] [http://psisemiya.com/images/small/programma-copertina/ programma copertina cd] [http://ustall.org/web/que-pides.htm que pides tu] [http://psisemiya.com/images/small/code-satellite/ code satellite tps] [http://helmed.info/topic/usl-feltre/ usl feltre] [http://bloprofeldi.info/lib/cooper-gordon.htm cooper, gordon leroy] [http://amohseni.info/img/styles/ivan-delphi/ ivan delphi] [http://ustall.org/web/big-bolls.htm big bolls] [http://psisemiya.com/images/small/multifunzione-fax/ multifunzione fax canon] [http://helmed.info/topic/cavo-hard/ cavo hard disk] [http://saibso.org/golf-.htm golf 1 9 tdi comfortline nuova] [http://kinunia.cn/golosa-king.htm golosa king africa] [http://ustall.org/web/partido-en.htm partido en vivo de los tiburones] [http://ashythro.info/library/html/berluska/ berluska] [http://saibso.org/i-t.htm i t c beltrami] [http://nobinters.org/forza-venite.htm forza venite] [http://bloprofeldi.info/lib/la-girandola.htm la girandola snc] [http://chaba.info/partita-mondiale/ partita mondiale calcio] [http://saibso.org/lynyrd-skynyrd.htm lynyrd skynyrd] [http://psisemiya.com/images/small/bigliettini-per/ bigliettini per la prima comunione] [http://davte.info/library/html/integratori-fibre.htm integratori fibre] [http://kinunia.cn/auto-frog.htm auto frog sumo] [http://nobinters.org/jessica-pare.htm jessica pare] [http://ashythro.info/library/html/ixus-/ ixus 50 canon] [http://davte.info/library/html/edyta-bartosiewicz.htm edyta bartosiewicz krawczyk trudno tak] [http://helmed.info/topic/francesca-neri/ francesca neri] [http://psisemiya.com/images/small/diffusori/ diffusori 7 1] [http://amohseni.info/img/styles/sabbatucci-e/ sabbatucci e vidotto] [http://davte.info/library/html/famosas-desnudas.htm famosas desnudas deportistas] [http://chaba.info/c-s/ c s computer  software srl] [http://nobinters.org/gazzetta-sport.htm gazzetta sport] [http://amohseni.info/img/styles/palmare-occasione/ palmare occasione] [http://psisemiya.com/images/small/lg-lcd/ lg lcd rz-37lz30] [http://amohseni.info/img/styles/lirik-lagu/ lirik lagu melayu] [http://psisemiya.com/images/small/emozion/ emozion] [http://amohseni.info/img/styles/iomega-hard/ iomega hard disk drive] [http://nobinters.org/s-s.htm s s c n] [http://bloprofeldi.info/lib/sodimm-mb.htm sodimm 256mb ddr 333mhz pc2700] [http://kinunia.cn/yamaha-xt.htm yamaha xt] [http://kinunia.cn/revamped.htm revamped] [http://saibso.org/per-fare.htm per fare quiz patentino] [http://davte.info/library/html/rsmmc-.htm rs-mmc 512 dual voltage 6630] [http://psisemiya.com/images/small/cf-card/ cf card gprs] [http://davte.info/library/html/lettori-dvd.htm lettori dvd e divx pioneer] [http://helmed.info/topic/rikki-pure/ rikki pure heart] [http://kinunia.cn/disegno-sul.htm disegno sul muro] [http://bloprofeldi.info/lib/spa.htm spa] [http://ashythro.info/library/html/zoom-x/ zoom 6x] [http://helmed.info/topic/la-sorella/ la sorella di bruce lee] [http://psisemiya.com/images/small/macchine-/ macchine  truccate] [http://bloprofeldi.info/lib/adidas-mei.htm adidas mei] [http://kinunia.cn/hp-nx.htm hp nx 6110 p-m 740] [http://kinunia.cn/midnight-hour.htm midnight hour pickett] [http://bloprofeldi.info/lib/shantung.htm shantung] [http://ashythro.info/library/html/instant/ instant] [http://nobinters.org/portami-lontano.htm portami lontano] [http://ustall.org/web/www-disnay.htm www disnay] [http://amohseni.info/img/styles/televisore-/ televisore 29 100hz] [http://davte.info/library/html/lettori-dvd.htm lettori dvd vcd jpeg] [http://bloprofeldi.info/lib/km-fiat.htm km0 fiat multipla benzina auto km 0] [http://chaba.info/www-providian/ www providian com] [http://nobinters.org/giovanni-marchese.htm giovanni marchese] [http://bloprofeldi.info/lib/to-this.htm to this love] [http://nobinters.org/la-oreja.htm la oreja de van] [http://saibso.org/zucchero-fornaciari.htm zucchero fornaciari] [http://davte.info/library/html/zuccherifici.htm zuccherifici] [http://saibso.org/syncback.htm syncback] [http://chaba.info/pcgratis/ pcgratis] [http://saibso.org/ozon-ochi.htm ozon ochi tai] [http://bloprofeldi.info/lib/dove-rifarsi.htm dove rifarsi il seno] [http://amohseni.info/img/styles/cavo-rca/ cavo rca minijack] [http://ustall.org/web/emmanuil-cesare.htm emmanuil, cesare] [http://bloprofeldi.info/lib/mercedes-serie.htm mercedes serie ml roma] [http://helmed.info/topic/sito-beni/ sito beni culturali] [http://davte.info/library/html/bova-ultimo.htm bova ultimo] [http://amohseni.info/img/styles/cunha-euclydes/ cunha, euclydes da-] [http://psisemiya.com/images/small/supratutto/ supratutto] [http://davte.info/library/html/asrock-sm.htm asrock 939s56-m] [http://bloprofeldi.info/lib/hamlet-dvb.htm hamlet dvb] [http://bloprofeldi.info/lib/transfert.htm transfert] [http://chaba.info/portal/ portal] [http://saibso.org/polti-vaporetto.htm polti vaporetto eco pro 3000] [http://psisemiya.com/images/small/profumi-uomo/ profumi uomo herrera] [http://davte.info/library/html/jewel-lyrics.htm jewel lyrics spirit] [http://psisemiya.com/images/small/victoria-gemme/ victoria gemme snc] [http://psisemiya.com/images/small/marron-five/ marron five this love testo] [http://bloprofeldi.info/lib/bikini-micro.htm bikini micro] [http://amohseni.info/img/styles/accademia-di/ accademia di danza di montecarlo] [http://saibso.org/prince-of.htm prince of persia gioco] [http://amohseni.info/img/styles/enriko/ enriko] [http://davte.info/library/html/canzone-amicizia.htm canzone amicizia] [http://saibso.org/www-cupa.htm www cupa it] [http://bloprofeldi.info/lib/pigiama-uomo.htm pigiama uomo] [http://ustall.org/web/favola-di.htm favola di pinocchio] [http://saibso.org/mode-sector.htm mode sector] [http://ustall.org/web/terratec-t.htm terratec t2 usb 2 0 dvb-t] [http://amohseni.info/img/styles/boblbobl/ boblbobl] [http://kinunia.cn/abile.htm abile] [http://nobinters.org/rennie-john.htm rennie, john] [http://helmed.info/topic/fiat-cinquecento/ fiat cinquecento] [http://amohseni.info/img/styles/happy-hour/ happy hour] [http://chaba.info/la-pantera/ la pantera rossa] [http://chaba.info/www-google/ www google copm] [http://nobinters.org/casse-acustiche.htm casse acustiche mini] [http://nobinters.org/export-manager.htm export manager (regione lombardia - milano provincia)] [http://ustall.org/web/iomega-portable.htm iomega portable hard disk] [http://davte.info/library/html/giro-d.htm giro d italia 2001] [http://helmed.info/topic/casio-z/ casio z40] [http://psisemiya.com/images/small/ristoranti-caserta/ ristoranti caserta] [http://psisemiya.com/images/small/hotel-ad/ hotel ad amsterdam] [http://amohseni.info/img/styles/star-sailor/ star sailor] [http://helmed.info/topic/jeep-grand/ jeep grand cherokee 2002] [http://helmed.info/topic/pc-transfer/ pc transfer nec 313] [http://saibso.org/diciotto.htm diciotto] [http://ustall.org/web/scandalo-blaze.htm scandalo blaze] [http://helmed.info/topic/tunisia-hotel/ tunisia hotel] [http://davte.info/library/html/lisola-sconosciuta.htm lisola sconosciuta] [http://psisemiya.com/images/small/coltello/ coltello] [http://davte.info/library/html/offerte-pc.htm offerte pc] [http://psisemiya.com/images/small/alessia-merz/ alessia merz merz nuda] [http://nobinters.org/jura.htm jura 385] [http://helmed.info/topic/langelo-del/ langelo del ring] [http://bloprofeldi.info/lib/spugne-di.htm spugne di mare] [http://nobinters.org/da-rgb.htm da rgb a component] [http://kinunia.cn/notre-dame.htm notre dame des paris] [http://bloprofeldi.info/lib/i-case.htm i case ipod] [http://nobinters.org/test-drive.htm test drive off-road 3] [http://davte.info/library/html/ci-vediamo.htm ci vediamo marco masini] [http://bloprofeldi.info/lib/rx-v.htm rx v450] [http://nobinters.org/cerca-lassassino.htm cerca lassassino] [http://ustall.org/web/trailer-selen.htm trailer selen mpg free] [http://helmed.info/topic/www-fitnessring/ www fitnessring it] [http://saibso.org/trama-nozze.htm trama nozze di figaro] [http://psisemiya.com/images/small/abbinare-colori/ abbinare colori uguali] [http://psisemiya.com/images/small/big-angel/ big angel] [http://psisemiya.com/images/small/sigla-telefilm/ sigla telefilm buffy] [http://davte.info/library/html/festa-arma.htm festa arma carabiniere] [http://saibso.org/lisola-che.htm lisola che scotta] [http://amohseni.info/img/styles/giorgio-stefy/ giorgio stefy] [http://ustall.org/web/visitare-l.htm visitare l abruzzo] [http://amohseni.info/img/styles/spinaci/ spinaci] [http://psisemiya.com/images/small/nuova-espansione/ nuova espansione per anarchy online] [http://ustall.org/web/ml-.htm ml 2250 toner] [http://kinunia.cn/prostitutas-com.htm prostitutas com] [http://nobinters.org/le-avventure.htm le avventure di tarzan] [http://amohseni.info/img/styles/emanuela-nay/ emanuela nay] [http://ashythro.info/library/html/alfa-romeo/ alfa romeo gtv] [http://chaba.info/una-donna/ una donna due passioni] [http://saibso.org/ita-integrated.htm ita integrated technology automation] [http://psisemiya.com/images/small/suites-per/ suites per violoncello di bach] [http://amohseni.info/img/styles/nomadi-mediterraneo/ nomadi mediterraneo] [http://psisemiya.com/images/small/gommapiuma-materassi/ gommapiuma materassi] [http://ustall.org/web/festivalbar-blue.htm festivalbar blue 2004] [http://bloprofeldi.info/lib/oraziano.htm oraziano] [http://kinunia.cn/server-news.htm server news libero] [http://amohseni.info/img/styles/siemens-s/ siemens s645 gigaset] [http://nobinters.org/urbis.htm urbis] [http://bloprofeldi.info/lib/midi-sslazio.htm midi sslazio] [http://ashythro.info/library/html/donnald-it/ donnald it] [http://kinunia.cn/agriturismo-sorrento.htm agriturismo sorrento] [http://kinunia.cn/sexy-ebonies.htm sexy ebonies] [http://davte.info/library/html/orienta-giovani.htm orienta giovani] [http://amohseni.info/img/styles/christmas-sexi/ christmas sexi] [http://amohseni.info/img/styles/baktay-ervin/ baktay, ervin] [http://ashythro.info/library/html/noche-de/ noche de ronda] [http://davte.info/library/html/ssteb.htm ssteb] ==Introduction==
+
==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.
 
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.
  

Latest revision as of 10:09, 24 August 2007

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 (i.e. preference settings, color values, etc.), 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 needs to insert multiple records or rows of something --- 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 data from specific field.

echo $myplugin->get("firstname");

Example #2: 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.

$myprefsArray = $myplugin->get();

Bringing it all together

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

Setting default values

Let's say you're using the userdata functions to store color values that you then retrieve in a template include to colorize certain template elements accordingly. Without setting any default values, the template will likely have a bunch of un-colored parts that should have colors (think transparent backgrounds where a solid bg color is expected) --- which may look a bit screwy --- until the user goes in to your config form and actually sets some values for those colors. This is where defaults come in handy. Here's how you can do them...

Example #1 - Setting a default background color of "#cccccc" (light gray) for an html element that you're outputting with a php template include.

<?
# Gotta do this first before you try to store/retrieve any of your data
# You can think of it like setting the "mode" to "working data related to your plugin specifically"
$mycolors = new userdata('myplugin');

# If no value exists, set the default
if ( $mycolors->get("headerbg") == "" ) {
   $mycolors->set("headerbg", "cccccc");
}
?>

<div id="header" style="background-color: #<? echo $mycolors->get("headerbg"); ?>;">
 This is my header
</div>
Personal tools