Wrong column count with identical images in ct = images

Use GitHub to post bug reports and error descriptions for phpwcms. Describe your problem detailed!
Locked
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Wrong column count with identical images in ct = images

Post by pixelpeter »

If you use more the once the same image for the "image" contenttype
the calculation of the column count will break;

EXAMPLE 1:
6 times image "sample1.jpg" wich we want to have displayed in 3 column will give us a column count of 1

EXAMPLE 2:
5 times image "sample2.jpg" also in 3 column will give us a column count of 2

EXAMPLE 3:
Using 5 different images gives us the correct column count

THE PROBLEM SPOTTED:
Column calculation is based on the number of rows return by MySQL. Because we're selecting 6 times the same picture we will only get back one row from the database.

THE SOLUTION ??:
If we're sure the images we're selecting are also existing we could replace $temp_count_img with count($content["image_list"])
but I'm not sure what happens, if one of the selected images is missing ;-(

@Oliver: Is this right ?!? What do I have to keep in mind if I want to change this ?

Speaking about the image-sql-statement:

The current statement uses a lot of "or"s:

Code: Select all

SELECT f_id, f_thumb_preview, f_name, f_thumb_list 
FROM phpwcms_file 
WHERE (f_id=1 OR f_id=3 OR f_id=3 OR f_id=3 OR f_id=3);
Wouldn't it be quicker to use "in" ??:

Code: Select all

SELECT f_id, f_thumb_preview, f_name, f_thumb_list 
FROM phpwcms_file 
WHERE IN (1,2,3,4,5,6);
Should work if there's no more than 250 IDs (but don't exactly know if this limitation in MySQL still exists)
Locked