vendredi 17 avril 2015

Mysql query for only current user

I've started using the wpdatatables plugin, In the backend it has a place to enter a MySql query for it to create a table.


I have:



SELECT id, currentuserid, text, date_created
FROM `1items`
WHERE currentuserid = %d
ORDER BY `1items`.`currentuserid`


Which lists all the tables I need to pull from the database, however, I am wondering if there is a way to dynamically filter in MySql for only the current user's ID.


In the second column "currentuserid" it pulls all the user's ID's and inputs them into the table.


Example: If I am logged in as user ID 4 - I would like the query to filter out the other users -- as of now, The above query returns tables from all user ID's.


When searching wordpress stackexchange, I located this: PHP MySQL query - return results for current user only Which doesn't work, or I am not using it right with wpdatatables.


Thanks!


Aucun commentaire:

Enregistrer un commentaire