[wp-hackers] Creating / Inserting into Table named after WP Username

Gregory Lancaster greglancaster71 at gmail.com
Sun Aug 25 09:16:26 UTC 2013


I still don't understand the benefit of using usermeta vs my own database.
 I googled for information about it but don't see any strong opinions one
way or the other.

The only reason I am doing it this way is because I want to have a
historical record - Meaning show the whole table, including all rows, which
will be dated and include several rows.  wp_usermeta only allows for one
value per key and updating it results in the loss of the previous entry.
 That wont work for me.

Additionally, assuming I create a new table in the wordpress database and
associated each entry with the user->id that would still be a very messy
way to store the data for hundreds of users who all have 20-40 entries
each.  Am I missing something here?


On Sat, Aug 24, 2013 at 11:20 PM, Dion Hulse (dd32) <wordpress at dd32.id.au>wrote:

> 1. Use a single table.. no table-per-user.. ie. { user_id, timestamp,
> meta_key, meta_value }
>
> 2. Basic PHP:
> function whatever() {
>   global $current_user;
>   return $wpdb->insert( "my_table", array( 'user_id' => $current_user->ID,
> 'timestamp' => time(), 'meta_key' => 'something', 'meta_value' =>
> 'whatever' ) );
> }
>
>
> On 25 August 2013 16:06, Gregory Lancaster <greglancaster71 at gmail.com
> >wrote:
>
> > The way the information is being stored, and the information being
> stored,
> > really is easier with a database.  I need a historical view of
> everything a
> > user entered, along with a date stamp.  SQL makes this simple.  Why is a
> > separate DB a bad idea?  It is fully functional right now, with the
> > exception of it being dynamic per user.  Cant figure how to make use of
> the
> > *$current_user->user_login; *outside the loop in php.  I am trying to use
> > it to create a table name that matches the current username.
> >
> >
> >
> > On Sat, Aug 24, 2013 at 10:59 PM, Ryan McCue <lists at rotorised.com>
> wrote:
> >
> > > Gregory Lancaster wrote:
> > > > The idea is to create a profile page where users can store more data
> > than
> > > > they can normally.  Upload more than one picture etc.  If there is a
> > more
> > > > intelligent way to do this PLEASE share!  The user_meta is limited
> > > though,
> > > > thats why I opted to make my own db.
> > >
> > > You can store arrays or objects in the meta fields, which is the
> > > preferred way to handle something like this. Creating extra tables is
> > > not the correct way to do it.
> > >
> > > (Internally, these are run through serialize(), then unserialize() on
> > > access.)
> > >
> > > --
> > > Ryan McCue
> > > <http://ryanmccue.info/>
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list