Shazamgallery Problem w/MySQL
I'm trying to modify the shazamgallery.module so that when a user goes to create an image node, they see a list of only the Shazam galleries they have personally created, and not a list of galleries created by all users. This is the current db_query:
function shazamgallery_get_galleries($moderate = 'all') {
$galleries = array();
if ($moderate == 0 || $moderate == 1) {
$res = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type = 'gallery' AND n.status = 1 AND n.moderate = %d ORDER BY n.created DESC"), $moderate);
}I talked with Ber Kessels, the creator of the module, and his idea was the same as mine: simply refine the query to also look for node.uid = $user->uid. So this is what I figure it should then be:
function shazamgallery_get_galleries($moderate = 'all') {
$galleries = array();
if ($moderate == 0 || $moderate == 1) {
$res = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type = 'gallery' AND n.uid = %d AND n.status = 1 AND n.moderate = %d ORDER BY n.created DESC"), $user->uid, $moderate);
}This does not work - no error generated, just no user-created gallery list prints onto the node-create form. But: If I substitute the %d in "n.uid = %d" with a real user number that has created galleries, then the form element prints correctly - i.e., it will load only the galleries created by that user.
So I am obviously on the right track here, but my syntax must be wrong. For hours I've tried every possible syntax combination I can think of to get this to work, with no luck. I figure one of you geniuses will see what I'm doing wrong in about five seconds. This is because you are better coders than me. And when you do type that solution below, I will bow down to the floor in thanks (no kissing, though... :-)
