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

Dion Hulse (dd32) wordpress at dd32.id.au
Sun Aug 25 06:20:48 UTC 2013


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
>


More information about the wp-hackers mailing list