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

Nicholas Ciske nl at thoughtrefinery.com
Mon Aug 26 18:11:28 UTC 2013


Use one row per entry, each row has a user (user_id) and date (as well as a auto incrementing primary key).

id - auto-incrementing primary key
user_id - WP user ID (index this column)
entry_date - date this entry was made (could be a date YYYYMMDD or unix timestamp depending on your needs)
(add other columns as needed)

get all rows for a user
SELECT * FROM table_name WHERE user_id = '1';

insert a new row for a user
INSERT INTO table_name (user_id, entry_date, ... ) values ( '1', CURDATE, ... ); // this is just psedocode

You can also query this schema by date (e.g. all entries between dates for a user or all users, etc).

> I tried INSERT INTO $table and that wont work, nor will
> any variation with quotes or curly brackets.


If you're getting errors, sharing those error messages, along with your DB schema and relvant code will go a long way towards getting help -- right now you’re getting high level advice as there's not way to give specific feedback.

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske	

On Aug 26, 2013, at 12:53 PM, Gregory Lancaster wrote:

> I considered that, but I have no idea how to match the user id owning a
> row- I am trying to figure that out now.  Its actually why I posted here,
> looking for a way to grab the active user ID or login_name and match it to
> a table or row.  I tried INSERT INTO $table and that wont work, nor will
> any variation with quotes or curly brackets.



More information about the wp-hackers mailing list