Re: [Phplib-users] Editing user variables?
Brought to you by:
nhruby,
richardarcher
From: Nathaniel P. <np...@te...> - 2003-08-27 20:35:35
|
----- Original Message ----- From: "Andy Fundinger" <an...@bu...> To: <php...@li...> Sent: Wednesday, August 27, 2003 11:35 AM Subject: [Phplib-users] Editing user variables? > Is there an easy way to access other user's variables? I'd really like to > do things like browse through all my users and edit their real names or add > a value to all current users without having to write the tool for it > entirely from scratch. Not really, no. User variables are stored in a serialized form in the database, just like session variables, thus the information is only accessible after it is deserialized and imported into variables (which the User class does transparently). Additionally, to save the changes back to the database, you'll need to reserialize /all/ the data and put it back in the database. Thus you'll only be able read and change the data from one user at a time. If I were to create such a tool, I'd look at the User (and Session, if you don't use session4.inc) class code and see about using the serialize() and deserialize() functions to get the data in and out. You might even be able to use the classes themselves with some modifications. Be aware that there would be significant limitations to it. You wouldn't be able to search in the DB for a specific user variable setting, for instance, and there's the aforementioned problem of needing to deserialize and reserialize /all/ the data in order to change any of it. Also, you will have to perform an update for each individual user where you change any of their user data. (i.e. Modifying 20 users, even if the modification is the same, means doing 20 updates to the database). If you're storing data in user variables that you need to access and/or change like this frequently, you might consider adding some hard-coded columns to your database and putting the data there, so that it's easier to use it. In any case I'm not aware that any pre-built tool to do what you're wanting to do exists, so you'll probably have to code up something yourself. Good luck. _________________________________ Nathaniel Price Webmaster <http://www.tesseract.net> |