PDA

View Full Version : Attachments query to get files and thumbnails?


Boofo
09-12-2005, 04:31 AM
Can anyone help me translate this to 3.5? I used this on 3.0 and it worked as designed. But something has changed as now attached thumbails show up as files with this query. I want to be able to pull out the amount of images and the amount of files.

$attachs=$db->query_first("
SELECT forum.title AS forum, COUNT(attachment.attachmentid) AS count, SUM(IF(thumbnail = '', 0, 1)) AS thumbs, SUM(IF(thumbnail = '', 1, 0)) AS files, SUM(attachment.filesize) AS bytes
FROM " . TABLE_PREFIX . "attachment AS attachment, " . TABLE_PREFIX . "post AS post, " . TABLE_PREFIX . "thread AS thread, " . TABLE_PREFIX . "forum AS forum
WHERE attachment.postid = post.postid
AND post.threadid=thread.threadid
AND forum.forumid=thread.forumid
AND forum.forumid=$forumid
GROUP BY thread.forumid
ORDER BY count DESC
");

Boofo
09-13-2005, 09:55 AM
I know this is the part that has changed. Anyone have any idea what I need to change this to to put the img count and files count out of the query?


SUM(IF(thumbnail = '', 0, 1)) AS thumbs, SUM(IF(thumbnail = '', 1, 0)) AS files

lexx27
10-21-2005, 09:43 PM
I dont know if we want the same thing. I need a hack that will let me download to my hard drive all the attachments as files!!!