Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
306 views
in Q2A Core by
I'm making a plugin that adds a gallery page where the user can add its own art/images/... . The upload works fine, the blobs have the correct user-id, but now I don't know how I'd fetch all the blobs uploaded by a particular user. How would one do so?
Q2A version: 1.6.1

2 Answers

+1 vote
by
edited by

Blobs are stored in the table qa_blobs together with the matching userid

 

Now a function or database call to get all blob ids of a specific user should be:

 

$result = qa_db_read_all_assoc(qa_db_query_sub("SELECT blobid FROM ^blobs WHERE userid =  '$myuserid' "));

(please hold in mind that i am no expert...so there may be better ways...)

 

EDIT 1:

logged in user id      --->         qa_get_logged_in_userid()

EDIT 2:

See here, may be there are some hints as well...

http://www.question2answer.org/qa/15565/how-to-check-on-question-view-page-if-post-is-by-logged-in-user

by
I used the code I posted as an answer instead, you put me on the right track, thanks!!!
0 votes
by

This code worked : 

 

$userid = qa_get_logged_in_userid();
$result = qa_db_query_sub("SELECT * FROM ^blobs WHERE userid =  '$userid' ");
 
while ($blob = mysql_fetch_array($result)) {
    $html .= '<tr><img src="'.qa_get_blob_url($blob['blobid'],true).'"></tr>';
}
 
...